Skip to content

Commit

Permalink
fix #43 ERR Script attempted to access a non local key in a cluster n…
Browse files Browse the repository at this point in the history
…ode script (#44)
  • Loading branch information
wesleywu authored Nov 25, 2024
1 parent a6968e5 commit 3beb6ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lua/reentrantLock.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local lock_key = KEYS[1]
local lock_key = '{' .. KEYS[1] .. '}'
local lock_value = ARGV[1]
local lock_ttl = tonumber(ARGV[2])
local reentrant_key = lock_key .. ':count:' .. lock_value
Expand All @@ -19,4 +19,4 @@ if redis.call('SET', lock_key, lock_value, 'NX', 'PX', lock_ttl) then
return "OK"
end

return nil
return nil
4 changes: 2 additions & 2 deletions lua/reentrantRenew.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local lock_key = KEYS[1]
local lock_key = '{' .. KEYS[1] .. '}'
local lock_value = ARGV[1]
local lock_ttl = tonumber(ARGV[2])
local reentrant_key = lock_key .. ':count:' .. lock_value
Expand All @@ -13,4 +13,4 @@ if reentrant_count > 0 or redis.call('GET', lock_key) == lock_value then
return "OK"
end

return nil
return nil
4 changes: 2 additions & 2 deletions lua/reentrantUnLock.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local lock_key = KEYS[1]
local lock_key = '{' .. KEYS[1] .. '}'
local lock_value = ARGV[1]
local reentrant_key = lock_key .. ':count:' .. lock_value
local reentrant_count = tonumber(redis.call('GET', reentrant_key) or '0')
Expand All @@ -23,4 +23,4 @@ if redis.call('GET', lock_key) == lock_value then
return "OK"
end

return nil
return nil

0 comments on commit 3beb6ab

Please sign in to comment.