You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
295 B
18 lines
295 B
1 month ago
|
--[[
|
||
|
Takes a lock
|
||
|
|
||
|
Input:
|
||
|
KEYS[1] 'lock',
|
||
|
|
||
|
ARGV[1] token
|
||
|
ARGV[2] lock duration in milliseconds
|
||
|
|
||
|
Output:
|
||
|
"OK" if lock taken successfully.
|
||
|
]]
|
||
|
if redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2]) then
|
||
|
return 1
|
||
|
else
|
||
|
return 0
|
||
|
end
|