There was an error while loading. Please reload this page.
1 parent 054546e commit d6e10e4Copy full SHA for d6e10e4
spring-boot-demo-ratelimit-redis/src/main/resources/scripts/redis/limit.lua
@@ -10,11 +10,11 @@ local max = tonumber(ARGV[4])
10
-- 移除指定分数区间内的所有元素,expired 即已经过期的 score
11
-- 根据当前时间毫秒数 - 超时毫秒数,得到过期时间 expired
12
redis.call('zremrangebyscore', key, 0, expired)
13
--- 获取 zset 中的元素个数
14
-local current = tonumber(redis.call('zcard', key))
15
16
---
+-- 获取 zset 中的当前元素个数
+local current = tonumber(redis.call('zcard', key))
17
local next = current + 1
+
18
if next > max then
19
-- 达到限流大小 返回 0
20
return 0;
0 commit comments