We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
else -- 没有达到阈值 value + 1 redis.call("INCRBY", key, 1) redis.call("EXPIRE", key, 2) return curentLimit + 1 end
The text was updated successfully, but these errors were encountered:
脚本有问题,应该这么写 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) if curentLimit == 0 then redis.call("EXPIRE", key, 1) return curentLimit + 1 end
Sorry, something went wrong.
No branches or pull requests
else
-- 没有达到阈值 value + 1
redis.call("INCRBY", key, 1)
redis.call("EXPIRE", key, 2)
return curentLimit + 1
end
The text was updated successfully, but these errors were encountered: