local prefix = KEYS[1]
local locked = redis.call('HGET', prefix, 'lock')
if locked then
- local host = redis.call('HGET', prefix, 'hostname')
+ local host = redis.call('HGET', prefix, 'hostname') or 'unknown'
return string.format('%s:%s', hostname, locked)
end
local nspam = 0
locked = tonumber(locked)
local expire = tonumber(KEYS[3])
if now > locked and (now - locked) < expire then
- return {tostring(locked), redis.call('HGET', KEYS[1], 'hostname')}
+ return {tostring(locked), redis.call('HGET', KEYS[1], 'hostname') or 'unknown'}
end
end
redis.call('HSET', KEYS[1], 'lock', tostring(now))