mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
8a622545ff
- laravel/framework ^12.0 -> ^13.0 (installed 13.19.0) - laravel/tinker ^2.9 -> ^3.0 (installed 3.0.2, pulls psysh >=0.12.19) - phpunit/phpunit ^11.0 -> ^12.0 (installed 12.5.31) - Symfony components move to 8.x (supported by L13); symfony/yaml stays on patched 7.4.14 via its direct ^7.0 constraint - league/commonmark auto-bumped to 2.8.2 (patched) - No application/config code changes required; the fluent validateCsrfTokens(except: ...) config still resolves under L13 composer audit: No security vulnerability advisories found. Full suite green: 59 tests, 128 assertions (1 skipped).
98 lines
2.1 KiB
PHP
98 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Illuminate\Cache;
|
|
|
|
class RedisLock extends Lock
|
|
{
|
|
/**
|
|
* The Redis factory implementation.
|
|
*
|
|
* @var \Illuminate\Redis\Connections\Connection
|
|
*/
|
|
protected $redis;
|
|
|
|
/**
|
|
* Create a new lock instance.
|
|
*
|
|
* @param \Illuminate\Redis\Connections\Connection $redis
|
|
* @param string $name
|
|
* @param int $seconds
|
|
* @param string|null $owner
|
|
*/
|
|
public function __construct($redis, $name, $seconds, $owner = null)
|
|
{
|
|
parent::__construct($name, $seconds, $owner);
|
|
|
|
$this->redis = $redis;
|
|
}
|
|
|
|
/**
|
|
* Attempt to acquire the lock.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function acquire()
|
|
{
|
|
if ($this->seconds > 0) {
|
|
return $this->redis->set($this->name, $this->owner, 'EX', $this->seconds, 'NX') == true;
|
|
}
|
|
|
|
return $this->redis->setnx($this->name, $this->owner) === 1;
|
|
}
|
|
|
|
/**
|
|
* Attempt to refresh the lock for the given number of seconds.
|
|
*
|
|
* @param int|null $seconds
|
|
* @return bool
|
|
*/
|
|
public function refresh($seconds = null)
|
|
{
|
|
$seconds ??= $this->seconds;
|
|
|
|
return (bool) $this->redis->eval(
|
|
LuaScripts::refreshLock(), 1, $this->name, $this->owner, $seconds
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Release the lock.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function release()
|
|
{
|
|
return (bool) $this->redis->eval(LuaScripts::releaseLock(), 1, $this->name, $this->owner);
|
|
}
|
|
|
|
/**
|
|
* Releases this lock in disregard of ownership.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function forceRelease()
|
|
{
|
|
$this->redis->del($this->name);
|
|
}
|
|
|
|
/**
|
|
* Returns the owner value written into the driver for this lock.
|
|
*
|
|
* @return string|null
|
|
*/
|
|
protected function getCurrentOwner()
|
|
{
|
|
return $this->redis->get($this->name);
|
|
}
|
|
|
|
/**
|
|
* Get the name of the Redis connection being used to manage the lock.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getConnectionName()
|
|
{
|
|
return $this->redis->getName();
|
|
}
|
|
}
|