Skip to content

Commit

Permalink
Set expiration when knobs hash exists (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Kemp committed Feb 21, 2019
1 parent d9b53f7 commit 56d9135
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions limitlion/throttle.lua
Expand Up @@ -111,17 +111,17 @@ local knobs_key = name .. ":knobs"
-- to manually override the setting for any throttle.
local knobs = redis.call("HMGET", knobs_key, "rps", "burst", "window")
if knobs[1] == false then
-- Set defaults if knobs hash is not found
-- Use defaults if knobs hash is not found
rps = tonumber(default_rps)
burst = tonumber(default_burst)
window = tonumber(default_window)
else
rps = tonumber(knobs[1])
burst = tonumber(knobs[2])
window = tonumber(knobs[3])
-- Expire knobs hash 7 days after last time used
redis.call("EXPIRE", knobs_key, 604800)
end
-- Expire knobs hash 7 days after last time used
redis.call("EXPIRE", knobs_key, 604800)

-- Use redis server time so it is consistent across callers
-- The following line gets replaced before loading this script during tests
Expand Down

0 comments on commit 56d9135

Please sign in to comment.