Created
March 24, 2014 15:02
-
-
Save losinggeneration/9741856 to your computer and use it in GitHub Desktop.
Warlock Lua->Moon (just for fun)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Set a lock | |
-- | |
-- KEYS[1] - key | |
-- KEYS[2] - ttl in ms | |
-- KEYS[3] - lock content | |
{key, ttl, content} = KEYS | |
lockSet = redis.call 'setnx', key, content | |
redis.call 'pexpire', key, ttl if lockSet == 1 | |
lockSet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local key, ttl, content | |
do | |
local _obj_0 = KEYS | |
key, ttl, content = _obj_0[1], _obj_0[2], _obj_0[3] | |
end | |
local lockSet = redis.call('setnx', key, content) | |
if lockSet == 1 then | |
redis.call('pexpire', key, ttl) | |
end | |
return lockSet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Set a lock | |
-- | |
-- KEYS[1] - key | |
-- KEYS[2] - ttl in ms | |
-- KEYS[3] - lock content | |
local key = KEYS[1] | |
local ttl = KEYS[2] | |
local content = KEYS[3] | |
local lockSet = redis.call('setnx', key, content) | |
if lockSet == 1 then | |
redis.call('pexpire', key, ttl) | |
end | |
return lockSet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment