Skip to content

Commit d6e10e4

Browse files
committed
💡 添加源码注释
1 parent 054546e commit d6e10e4

File tree

1 file changed

+3
-3
lines changed
  • spring-boot-demo-ratelimit-redis/src/main/resources/scripts/redis

1 file changed

+3
-3
lines changed

spring-boot-demo-ratelimit-redis/src/main/resources/scripts/redis/limit.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ local max = tonumber(ARGV[4])
1010
-- 移除指定分数区间内的所有元素,expired 即已经过期的 score
1111
-- 根据当前时间毫秒数 - 超时毫秒数,得到过期时间 expired
1212
redis.call('zremrangebyscore', key, 0, expired)
13-
-- 获取 zset 中的元素个数
14-
local current = tonumber(redis.call('zcard', key))
1513

16-
--
14+
-- 获取 zset 中的当前元素个数
15+
local current = tonumber(redis.call('zcard', key))
1716
local next = current + 1
17+
1818
if next > max then
1919
-- 达到限流大小 返回 0
2020
return 0;

0 commit comments

Comments
 (0)