Sha256: aaa873349e3592ee28ff308dfa34cbd043c428df8911f79fb85633a5690bd0f7

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

local exists_key    = KEYS[1]
local grabbed_key   = KEYS[2]
local available_key = KEYS[3]
local version_key   = KEYS[4]
local unique_keys   = KEYS[5]
local unique_digest = KEYS[6] -- TODO: Legacy support (Remove in v6.1)

local token      = ARGV[1]
local expiration = tonumber(ARGV[2])

redis.call('HDEL', grabbed_key, token)
redis.call('SREM', unique_keys, unique_digest)

if expiration then
  redis.log(redis.LOG_DEBUG, "signal_locks.lua - expiring stale locks")
  redis.call('SREM', unique_keys, unique_digest)
  redis.call('EXPIRE', exists_key, expiration)
  redis.call('EXPIRE', available_key, expiration)
  redis.call('EXPIRE', version_key, expiration)   -- TODO: Legacy support (Remove in v6.1)
  redis.call('EXPIRE', unique_digest, expiration) -- TODO: Legacy support (Remove in v6.1)
else
  redis.call('DEL', exists_key)
  redis.call('SREM', unique_keys, unique_digest)
  redis.call('DEL', grabbed_key)
  redis.call('DEL', available_key)
  redis.call('DEL', version_key)    -- TODO: Legacy support (Remove in v6.1)
  redis.call('DEL', 'uniquejobs')   -- TODO: Old job hash, just drop the darn thing  (Remove in v6.1)
  redis.call('DEL', unique_digest)  -- TODO: Legacy support (Remove in v6.1)
end

local count = redis.call('LPUSH', available_key, token)
redis.call('EXPIRE', available_key, 5)
return count

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-6.0.10 redis/unlock.lua
sidekiq-unique-jobs-6.0.9 redis/unlock.lua
sidekiq-unique-jobs-6.0.8 redis/unlock.lua