Sha256: cd2bc87c5be4264143602b8cafceb067ae5cc82440608b482236fd4d1a4f3419

Contents?: true

Size: 720 Bytes

Versions: 4

Compression:

Stored size: 720 Bytes

Contents

local locker_id = ARGV[1]
local lock_key  = ARGV[2]
local exclusive = ARGV[3]

if redis.call('EXISTS', locker_id) == 1 then
  local actual_lock_key = redis.call('HGET', locker_id, 'key')
  local actual_exclusive = redis.call('HGET', locker_id, 'exclusive')

  local error_message = "Lock " .. lock_key .. " (exclusive=" .. exclusive .. ") fail. Alradey locked by " .. actual_lock_key .. " (exclusive=" .. actual_exclusive .. ")"

  if exclusive == "true" or
     actual_exclusive == 'true'  or
     actual_lock_key ~= lock_key then
    
    error(error_message)
  end 
end

redis.call('HSET', locker_id, 'key', lock_key)
redis.call('HSET', locker_id, 'exclusive', exclusive)
redis.call("HINCRBY", locker_id, 'nested', 1)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
restruct-1.1.0 lua/register.lua
restruct-1.0.0 lua/register.lua
restruct-0.2.0 lua/register.lua
restruct-0.1.0 lua/register.lua