diff --git a/src/Illuminate/Cache/RedisStore.php b/src/Illuminate/Cache/RedisStore.php index f953d30d585..566913389dc 100755 --- a/src/Illuminate/Cache/RedisStore.php +++ b/src/Illuminate/Cache/RedisStore.php @@ -292,10 +292,15 @@ protected function currentTags($chunkSize = 1000) default => '', }; + $defaultCursorValue = match (true) { + $connection instanceof PhpRedisConnection && version_compare(phpversion('redis'), '6.1.0', '>=') => null, + default => '0', + }; + $prefix = $connectionPrefix.$this->getPrefix(); - return LazyCollection::make(function () use ($connection, $chunkSize, $prefix) { - $cursor = $defaultCursorValue = '0'; + return LazyCollection::make(function () use ($connection, $chunkSize, $prefix, $defaultCursorValue) { + $cursor = $defaultCursorValue; do { [$cursor, $tagsChunk] = $connection->scan( diff --git a/src/Illuminate/Cache/RedisTagSet.php b/src/Illuminate/Cache/RedisTagSet.php index 072a01bc236..c6aea191a83 100644 --- a/src/Illuminate/Cache/RedisTagSet.php +++ b/src/Illuminate/Cache/RedisTagSet.php @@ -2,6 +2,7 @@ namespace Illuminate\Cache; +use Illuminate\Redis\Connections\PhpRedisConnection; use Illuminate\Support\Carbon; use Illuminate\Support\LazyCollection; @@ -35,12 +36,19 @@ public function addEntry(string $key, ?int $ttl = null, $updateWhen = null) */ public function entries() { - return LazyCollection::make(function () { + $connection = $this->store->connection(); + + $defaultCursorValue = match (true) { + $connection instanceof PhpRedisConnection && version_compare(phpversion('redis'), '6.1.0', '>=') => null, + default => '0', + }; + + return LazyCollection::make(function () use ($connection, $defaultCursorValue) { foreach ($this->tagIds() as $tagKey) { - $cursor = $defaultCursorValue = '0'; + $cursor = $defaultCursorValue; do { - [$cursor, $entries] = $this->store->connection()->zscan( + [$cursor, $entries] = $connection->zscan( $this->store->getPrefix().$tagKey, $cursor, ['match' => '*', 'count' => 1000]