Skip to content

[Lock] Make sure RedisStore will also support Valkey #59488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Symfony/Component/Lock/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RedisStore implements SharedLockStoreInterface
{
use ExpiringStoreTrait;

private const NO_SCRIPT_ERROR_MESSAGE = 'NOSCRIPT No matching script. Please use EVAL.';
private const NO_SCRIPT_ERROR_MESSAGE_PREFIX = 'NOSCRIPT No matching script.';

private bool $supportTime;

Expand Down Expand Up @@ -234,7 +234,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
$this->redis->clearLastError();

$result = $this->redis->evalSha($scriptSha, array_merge([$resource], $args), 1);
if (self::NO_SCRIPT_ERROR_MESSAGE === $err = $this->redis->getLastError()) {
if (null !== ($err = $this->redis->getLastError()) && str_starts_with($err, self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
$this->redis->clearLastError();

if ($this->redis instanceof \RedisCluster) {
Expand Down Expand Up @@ -263,7 +263,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
$client = $this->redis->_instance($this->redis->_target($resource));
$client->clearLastError();
$result = $client->evalSha($scriptSha, array_merge([$resource], $args), 1);
if (self::NO_SCRIPT_ERROR_MESSAGE === $err = $client->getLastError()) {
if (null !== ($err = $this->redis->getLastError()) && str_starts_with($err, self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
$client->clearLastError();

$client->script('LOAD', $script);
Expand All @@ -285,7 +285,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
\assert($this->redis instanceof \Predis\ClientInterface);

$result = $this->redis->evalSha($scriptSha, 1, $resource, ...$args);
if ($result instanceof Error && self::NO_SCRIPT_ERROR_MESSAGE === $result->getMessage()) {
if ($result instanceof Error && str_starts_with($result->getMessage(), self::NO_SCRIPT_ERROR_MESSAGE_PREFIX)) {
$result = $this->redis->script('LOAD', $script);
if ($result instanceof Error) {
throw new LockStorageException($result->getMessage());
Expand Down