@@ -29,7 +29,7 @@ class RedisStore implements SharedLockStoreInterface
29
29
{
30
30
use ExpiringStoreTrait;
31
31
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. ' ;
33
33
34
34
private bool $ supportTime ;
35
35
@@ -234,7 +234,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
234
234
$ this ->redis ->clearLastError ();
235
235
236
236
$ 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 )) {
238
238
$ this ->redis ->clearLastError ();
239
239
240
240
if ($ this ->redis instanceof \RedisCluster) {
@@ -263,7 +263,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
263
263
$ client = $ this ->redis ->_instance ($ this ->redis ->_target ($ resource ));
264
264
$ client ->clearLastError ();
265
265
$ 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 )) {
267
267
$ client ->clearLastError ();
268
268
269
269
$ client ->script ('LOAD ' , $ script );
@@ -285,7 +285,7 @@ private function evaluate(string $script, string $resource, array $args): mixed
285
285
\assert ($ this ->redis instanceof \Predis \ClientInterface);
286
286
287
287
$ 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 )) {
289
289
$ result = $ this ->redis ->script ('LOAD ' , $ script );
290
290
if ($ result instanceof Error) {
291
291
throw new LockStorageException ($ result ->getMessage ());
0 commit comments