Skip to content

Commit 5eb107c

Browse files
authored
Update redis.lua
1 parent c3a13e5 commit 5eb107c

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

lua/redis.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
local _M = {}
22
local redis = require("resty.redis")
3-
local CACHE_THRESHOLD = 0.001
43

54
-- reference: https://redis.io/learn/develop/dotnet/aspnetcore/rate-limiting/sliding-window
65
local SLIDING_WINDOW_SCRIPT = [[
@@ -49,15 +48,6 @@ function _M.throttle(ngx, cache_key, rule, cache)
4948
return false
5049
end
5150

52-
if res == 1 then
53-
local ttl, err = red:pttl(cache_key)
54-
if ttl and ttl/1000 > CACHE_THRESHOLD then
55-
require('util').add_to_local_cache(ngx, cache, cache_key, 1, ttl/1000)
56-
elseif err then
57-
ngx.log(ngx.ERR, "failed to fetch TTL: ", err)
58-
end
59-
end
60-
6151
local ok, err = red:set_keepalive(10000, 100)
6252
if not ok then
6353
ngx.log(ngx.ERR, "failed to set keepalive: ", err)

0 commit comments

Comments
 (0)