We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent afe5cf9 commit 77c2b55Copy full SHA for 77c2b55
src/index.ts
@@ -46,14 +46,18 @@ const EXTEND_SCRIPT = `
46
const RELEASE_SCRIPT = `
47
local count = 0
48
for i, key in ipairs(KEYS) do
49
- -- Only remove entries for *this* lock value.
50
- if redis.call("get", key) == ARGV[1] then
+ local v = redis.call("get", key)
+ if v == false then
51
+ -- Key already missing/expired: treat as success.
52
+ count = count + 1
53
+ elseif v == ARGV[1] then
54
+ -- Matches our lock value: delete and count as success.
55
redis.pcall("del", key)
56
count = count + 1
57
end
58
-
- -- Return the number of entries removed.
59
+
60
+ -- Return the number of entries removed or already missing.
61
return count
62
`;
63
0 commit comments