init project v1.0.0
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.central.common.redis.RedisAutoConfigure
|
||||
@@ -0,0 +1,19 @@
|
||||
--lua 下标从 1 开始
|
||||
-- 限流 key
|
||||
local key = KEYS[1]
|
||||
-- 限流大小
|
||||
local limit = tonumber(ARGV[1])
|
||||
|
||||
-- 获取当前流量大小
|
||||
local curentLimit = tonumber(redis.call('get', key) or "0")
|
||||
|
||||
if curentLimit + 1 > limit then
|
||||
-- 达到限流大小 返回
|
||||
return 0;
|
||||
else
|
||||
-- 没有达到阈值 value + 1
|
||||
redis.call("INCRBY", key, 1)
|
||||
redis.call("EXPIRE", key, 2)
|
||||
return curentLimit + 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user