All Downloads are FREE. Search and download functionalities are using the official Maven repository.

easyopen_script.limit.lua Maven / Gradle / Ivy

Go to download

一个简单易用的接口开放平台,平台封装了常用的参数校验、结果返回等功能,开发者只需实现业务代码即可。https://gitee.com/durcframework/easyopen

There is a newer version: 1.16.20
Show newest version
local key = KEYS[1] --限流KEY(一秒一个)
local limit = tonumber(ARGV[1]) --限流大小
local current = tonumber(redis.call("get", key)) or 0
if current + 1 > limit then --如果超出限流大小
   return 0
else  --请求数+1,并设置2秒过期
   redis.call("INCRBY", key,"1")
   redis.call("expire", key,"2")
   return 1
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy