29 lines
679 B
Lua
29 lines
679 B
Lua
--[[
|
|
Adds a repeatable job
|
|
|
|
Input:
|
|
KEYS[1] 'repeat' key
|
|
|
|
ARGV[1] next milliseconds
|
|
ARGV[2] custom key
|
|
ARGV[3] legacy custom key TODO: remove this logic in next breaking change
|
|
|
|
Output:
|
|
repeatableKey - OK
|
|
]]
|
|
local rcall = redis.call
|
|
local repeatKey = KEYS[1]
|
|
local nextMillis = ARGV[1]
|
|
local customKey = ARGV[2]
|
|
local legacyCustomKey = ARGV[3]
|
|
|
|
if rcall("ZSCORE", repeatKey, customKey) then
|
|
rcall("ZADD", repeatKey, nextMillis, customKey)
|
|
return customKey
|
|
elseif rcall("ZSCORE", repeatKey, legacyCustomKey) ~= false then
|
|
rcall("ZADD", repeatKey, nextMillis, legacyCustomKey)
|
|
return legacyCustomKey
|
|
end
|
|
|
|
return ''
|