Skip to content

Commit 3540952

Browse files
bug #61161 [Lock] Fallback to eval when LOAD fails due to missing script (santysisi)
This PR was merged into the 7.2 branch. Discussion ---------- [Lock] Fallback to `eval` when `LOAD` fails due to missing script | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59795 | License | MIT * First attempts to execute the script using `evalSha`. * If the script is missing (NOSCRIPT), tries to load it using script `LOAD`. * If script `LOAD` is not supported, falls back to `eval`. Commits ------- 420d996 [Lock] Fallback to `eval` when `LOAD` fails due to missing script
2 parents a389683 + 420d996 commit 3540952

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ private function evaluate(string $script, string $resource, array $args): mixed
294294
}
295295
}
296296

297-
$this->handlePredisError(fn () => $this->redis->script('LOAD', $script));
297+
if ($this->redis->getConnection() instanceof \Predis\Connection\Cluster\ClusterInterface) {
298+
foreach ($this->redis as $connection) {
299+
$this->handlePredisError(fn () => $connection->script('LOAD', $script));
300+
}
301+
} else {
302+
$this->handlePredisError(fn () => $this->redis->script('LOAD', $script));
303+
}
298304

299305
return $this->handlePredisError(fn () => $this->redis->evalSha($scriptSha, 1, $resource, ...$args));
300306
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy