Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RLOCK = "redis.call('HSETNX', KEYS[1], 'mode', 'r'); local ret = redis.call('HGET', KEYS[1], 'mode'); if ret == 'r' then redis.call('EXPIRE', KEYS[1], ARGV[2]); return redis.call('HSETNX', KEYS[1], ARGV[1], 1) end"
- WLOCK = "local ret = redis.call('HSETNX', KEYS[1], 'mode', 'w'); if ret == 0 then return ret end; redis.call('EXPIRE', KEYS[1], ARGV[2]); return redis.call('HSETNX', KEYS[1], ARGV[1], 1)"
- RELEASE = "local ret = redis.call('HDEL', KEYS[1], ARGV[1]); local sz = redis.call('HLEN', KEYS[1]); if sz == 1 then redis.call('DEL', KEYS[1]) end; return ret"
- RENEW = "local ret = redis.call('HEXISTS', KEYS[1], ARGV[1]); if ret > 0 then ret = redis.call('EXPIRE', KEYS[1], ARGV[2]) end; return ret"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement