Skip to content

Commit

Permalink
Fix script running for RedisCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dciprian-petrisor committed Oct 10, 2024
1 parent e67c2a1 commit a3ea15c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Symfony/Component/Lock/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,13 @@ private function evaluate(string $script, string $resource, array $args): mixed
if (null !== ($err = $this->redis->getLastError()) && self::NO_SCRIPT_ERROR_MESSAGE === $err) {
$this->redis->clearLastError();

$this->redis->script('LOAD', $script);
if ($this->redis instanceof \RedisCluster) {
foreach ($this->redis->_masters() as $master) {
$this->redis->script($master, 'LOAD', $script);
}
} else {
$this->redis->script('LOAD', $script);
}

if (null !== ($err = $this->redis->getLastError())) {
throw new LockStorageException($err);
Expand All @@ -260,7 +266,13 @@ private function evaluate(string $script, string $resource, array $args): mixed
if (null !== ($err = $client->getLastError()) && self::NO_SCRIPT_ERROR_MESSAGE === $err) {
$client->clearLastError();

$client->script('LOAD', $script);
if ($this->redis instanceof \RedisCluster) {
foreach ($this->redis->_masters() as $master) {
$this->redis->script($master, 'LOAD', $script);
}
} else {
$this->redis->script('LOAD', $script);
}

if (null !== ($err = $client->getLastError())) {
throw new LockStorageException($err);
Expand Down

0 comments on commit a3ea15c

Please sign in to comment.