extendLock-2.lua 504 B

1234567891011121314151617181920212223
  1. --[[
  2. Extend lock and removes the job from the stalled set.
  3. Input:
  4. KEYS[1] 'lock',
  5. KEYS[2] 'stalled'
  6. ARGV[1] token
  7. ARGV[2] lock duration in milliseconds
  8. ARGV[3] jobid
  9. Output:
  10. "1" if lock extented succesfully.
  11. ]]
  12. local rcall = redis.call
  13. if rcall("GET", KEYS[1]) == ARGV[1] then
  14. -- if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2], "XX") then
  15. if rcall("SET", KEYS[1], ARGV[1], "PX", ARGV[2]) then
  16. rcall("SREM", KEYS[2], ARGV[3])
  17. return 1
  18. end
  19. end
  20. return 0