Skip to content

Commit bffc5c2

Browse files
Small changes related to PHP 7
1 parent 640ecae commit bffc5c2

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

classes/mutex/FlockMutex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class FlockMutex extends LockMutex
2222
{
23-
const INFINITE_TIMEOUT = -1;
23+
public const INFINITE_TIMEOUT = -1;
2424

2525
/**
2626
* @internal

classes/mutex/PredisMutex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function evalScript($client, string $script, int $numkeys, array $argu
5252
{
5353
/** @var ClientInterface $client */
5454
try {
55-
return $client->eval(...array_merge([$script, $numkeys], $arguments));
55+
return $client->eval($script, $numkeys, ...$arguments);
5656
} catch (PredisException $e) {
5757
$message = sprintf(
5858
"Failed to release lock at %s",

classes/mutex/RedisMutex.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,13 @@ protected function acquire(string $key, int $expire): bool
126126

127127
protected function release(string $key): bool
128128
{
129-
/*
130-
* Question for Redis: Why do I have to try to delete also keys
131-
* which I haven't acquired? I do observe collisions of the random
132-
* token, which results in releasing the wrong key.
133-
*/
134-
135129
/*
136130
* All Redis commands must be analyzed before execution to determine which keys the command will operate on. In
137131
* order for this to be true for EVAL, keys must be passed explicitly.
132+
*
133+
* @link https://redis.io/commands/set
138134
*/
139-
$script = '
140-
if redis.call("get",KEYS[1]) == ARGV[1] then
135+
$script = 'if redis.call("get",KEYS[1]) == ARGV[1] then
141136
return redis.call("del",KEYS[1])
142137
else
143138
return 0

tests/mutex/MutexConcurrencyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function tearDown()
5353
*
5454
* @return \PDO The PDO.
5555
*/
56-
private function getPDO($dsn, $user): \PDO
56+
private function getPDO(string $dsn, string $user): \PDO
5757
{
5858
if ($this->pdo === null) {
5959
$this->pdo = new \PDO($dsn, $user);

0 commit comments

Comments
 (0)