Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion redis_cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def get_cache_lua_fn(client):
local limit = tonumber(ARGV[3])
if limit > 0 then
local time_parts = redis.call('TIME')
local time = tonumber(time_parts[1] .. '.' .. time_parts[2])
-- TIME returns [seconds, microseconds] (as strings), so parse each
-- and add together to get the full timestamp
local time = tonumber(time_parts[1]) + (tonumber(time_parts[2]) / 1000000)
redis.call('ZADD', KEYS[2], time, KEYS[1])
local count = tonumber(redis.call('ZCOUNT', KEYS[2], '-inf', '+inf'))
local over = count - limit
Expand Down