PhpRedisLock.php 829 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Illuminate\Cache;
  3. use Illuminate\Redis\Connections\PhpRedisConnection;
  4. class PhpRedisLock extends RedisLock
  5. {
  6. /**
  7. * Create a new phpredis lock instance.
  8. *
  9. * @param \Illuminate\Redis\Connections\PhpRedisConnection $redis
  10. * @param string $name
  11. * @param int $seconds
  12. * @param string|null $owner
  13. * @return void
  14. */
  15. public function __construct(PhpRedisConnection $redis, string $name, int $seconds, ?string $owner = null)
  16. {
  17. parent::__construct($redis, $name, $seconds, $owner);
  18. }
  19. /**
  20. * {@inheritDoc}
  21. */
  22. public function release()
  23. {
  24. return (bool) $this->redis->eval(
  25. LuaScripts::releaseLock(),
  26. 1,
  27. $this->name,
  28. ...$this->redis->pack([$this->owner])
  29. );
  30. }
  31. }