Skip to content

Commit b01c781

Browse files
Fix missing index key in context
1 parent 680c60d commit b01c781

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

classes/mutex/RedisMutex.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ protected function acquire(string $key, int $expire): bool
7777
$errored = 0;
7878
$this->token = \random_bytes(16);
7979
$exception = null;
80-
foreach ($this->redisAPIs as $index => $redis) {
80+
foreach ($this->redisAPIs as $index => $redisAPI) {
8181
try {
82-
if ($this->add($redis, $key, $this->token, $expire)) {
82+
if ($this->add($redisAPI, $key, $this->token, $expire)) {
8383
$acquired++;
8484
}
8585
} catch (LockAcquireException $exception) {
@@ -135,15 +135,16 @@ protected function release(string $key): bool
135135
end
136136
';
137137
$released = 0;
138-
foreach ($this->redisAPIs as $redis) {
138+
foreach ($this->redisAPIs as $index => $redisAPI) {
139139
try {
140-
if ($this->evalScript($redis, $script, 1, [$key, $this->token])) {
140+
if ($this->evalScript($redisAPI, $script, 1, [$key, $this->token])) {
141141
$released++;
142142
}
143143
} catch (LockReleaseException $e) {
144144
// todo throw if there is only one redis server
145145
$context = [
146146
"key" => $key,
147+
"index" => $index,
147148
"token" => $this->token,
148149
"exception" => $e
149150
];

0 commit comments

Comments
 (0)