Skip to content

Commit 9c183b1

Browse files
committed
Treat negative key as no counter value
1 parent d9b1b6c commit 9c183b1

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/lua/cachedcounter.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ if redis.call("EXISTS", key) == 1 then
88
local sum = tonumber(redis.call("GET", key)) or 0;
99
if sum < 0 then
1010
redis.call("DEL", key);
11-
sum = 0
12-
else
13-
-- extend the life of this counter by ttl seconds
14-
redis.call("EXPIRE", key, ttl);
11+
return nil;
1512
end
16-
13+
14+
-- extend the life of this counter by ttl seconds
15+
redis.call("EXPIRE", key, ttl);
16+
1717
return sum;
1818
else
1919
return nil;

0 commit comments

Comments
 (0)