eee
This commit is contained in:
@@ -103,13 +103,13 @@ class Redis
|
||||
public function lock($key, int $timeout = 5): bool|int
|
||||
{
|
||||
$script = <<<SCRIPT
|
||||
local _nx = redis.call('setnx',KEYS[1], ARGV[1])
|
||||
if (_nx ~= 0) then
|
||||
redis.call('expire',KEYS[1], ARGV[1])
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
SCRIPT;
|
||||
local _nx = redis.call('setnx',KEYS[1], ARGV[1])
|
||||
if (_nx ~= 0) then
|
||||
redis.call('expire',KEYS[1], ARGV[1])
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
SCRIPT;
|
||||
return $this->eval($script, ['{lock}:' . $key, $timeout], 1);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ SCRIPT;
|
||||
try {
|
||||
return $client->{$name}(...$arguments);
|
||||
} catch (\Throwable $throwable) {
|
||||
return trigger_print_error(throwable($throwable));
|
||||
return $this->getLogger()->json_log($throwable, [], false);
|
||||
} finally {
|
||||
if ($client->ping('h') == 'h') {
|
||||
$this->pool()->push($this->getName(), $client);
|
||||
@@ -156,6 +156,15 @@ SCRIPT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Kiri\Error\StdoutLogger
|
||||
*/
|
||||
protected function getLogger(): Kiri\Error\StdoutLogger
|
||||
{
|
||||
return Kiri::getLogger();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Redis
|
||||
* @throws
|
||||
|
||||
Reference in New Issue
Block a user