Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b4e407

Browse filesBrowse files
PatNowakfabpot
PatNowak
authored andcommitted
[Lock] Make sure RedisStore will also support Valkey
1 parent d0cfffb commit 3b4e407
Copy full SHA for 3b4e407

File tree

1 file changed

+4
-4
lines changed
Filter options

1 file changed

+4
-4
lines changed

‎Store/RedisStore.php

Copy file name to clipboardExpand all lines: Store/RedisStore.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RedisStore implements SharedLockStoreInterface
2929
{
3030
use ExpiringStoreTrait;
3131

32-
private const NO_SCRIPT_ERROR_MESSAGE = 'NOSCRIPT No matching script. Please use EVAL.';
32+
private const NO_SCRIPT_ERROR_MESSAGE_PREFIX = 'NOSCRIPT No matching script.';
3333

3434
private bool $supportTime;
3535

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

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

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

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.