LuaScripts.php 462 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Illuminate\Cache;
  3. class LuaScripts
  4. {
  5. /**
  6. * Get the Lua script to atomically release a lock.
  7. *
  8. * KEYS[1] - The name of the lock
  9. * ARGV[1] - The owner key of the lock instance trying to release it
  10. *
  11. * @return string
  12. */
  13. public static function releaseLock()
  14. {
  15. return <<<'LUA'
  16. if redis.call("get",KEYS[1]) == ARGV[1] then
  17. return redis.call("del",KEYS[1])
  18. else
  19. return 0
  20. end
  21. LUA;
  22. }
  23. }