|
|
|
|
@ -46,6 +46,10 @@ class Redis extends Cache implements IMemcacheTTL { |
|
|
|
|
'if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end', |
|
|
|
|
'cf0e94b2e9ffc7e04395cf88f7583fc309985910', |
|
|
|
|
], |
|
|
|
|
'caSetTtl' => [ |
|
|
|
|
'if redis.call("get", KEYS[1]) == ARGV[1] then redis.call("expire", KEYS[1], ARGV[2]) return 1 else return 0 end', |
|
|
|
|
'fa4acbc946d23ef41d7d3910880b60e6e4972d72', |
|
|
|
|
], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -187,15 +191,9 @@ class Redis extends Cache implements IMemcacheTTL { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function compareSetTTL(string $key, mixed $value, int $ttl): bool { |
|
|
|
|
$fullKey = $this->getPrefix() . $key; |
|
|
|
|
$redis = $this->getCache(); |
|
|
|
|
if ($this->get($key) === $value) { |
|
|
|
|
$result = $redis->multi() |
|
|
|
|
->expire($fullKey, $ttl) |
|
|
|
|
->exec(); |
|
|
|
|
return $result !== false; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
$value = self::encodeValue($value); |
|
|
|
|
|
|
|
|
|
return $this->evalLua('caSetTtl', [$key], [$value, $ttl]) > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function isAvailable(): bool { |
|
|
|
|
|