$script = '
if redis.call("GET", KEYS[1]) == ARGV[1] then
return redis.call("PEXPIRE", KEYS[1], ARGV[2])
elseif redis.call("SET", KEYS[1], ARGV[1], "NX", "PX", ARGV[2]) then
return 1
else
return 0
end
';
if (!
$this->
evaluate($script,
(string) $key,
[$this->
getUniqueToken($key),
(int) ceil(5 * 1000
)])) { throw new LockConflictedException();
} } public function exists(Key
$key) { return $this->redis->
get((string) $key) ===
$this->
getUniqueToken($key);
} private function evaluate(string
$script, string
$resource, array
$args) { if ($this->redis instanceof \Redis ||
$this->redis instanceof Relay ||
$this->redis instanceof \RedisCluster
) {