diff --git a/src/Illuminate/Cache/RedisTaggedCache.php b/src/Illuminate/Cache/RedisTaggedCache.php index 7f4e30992a4a..c95abe4e5235 100644 --- a/src/Illuminate/Cache/RedisTaggedCache.php +++ b/src/Illuminate/Cache/RedisTaggedCache.php @@ -193,8 +193,18 @@ protected function flushValues() ->map(fn (string $key) => $this->store->getPrefix().$key) ->chunk(1000); + $connection = $this->store->connection(); + foreach ($entries as $cacheKeys) { - $this->store->connection()->del(...$cacheKeys); + if ($connection instanceof PredisClusterConnection) { + $connection->pipeline(function ($connection) use ($cacheKeys) { + foreach ($cacheKeys as $cacheKey) { + $connection->del($cacheKey); + } + }); + } else { + $connection->del(...$cacheKeys); + } } } diff --git a/tests/Integration/Cache/RedisStoreTest.php b/tests/Integration/Cache/RedisStoreTest.php index 42bbb5a02ff2..e4332b5b6b40 100644 --- a/tests/Integration/Cache/RedisStoreTest.php +++ b/tests/Integration/Cache/RedisStoreTest.php @@ -6,7 +6,6 @@ use Illuminate\Cache\RedisStore; use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis; use Illuminate\Redis\Connections\PhpRedisClusterConnection; -use Illuminate\Redis\Connections\PredisClusterConnection; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Sleep; use Mockery as m; @@ -96,8 +95,6 @@ public function testItCanExpireWithZeroTTL() public function testTagsCanBeAccessed() { - $this->markTestSkippedWithPredisClusterConnection(); - Cache::store('redis')->clear(); Cache::store('redis')->tags(['people', 'author'])->put('name', 'Sally', 5); @@ -114,8 +111,6 @@ public function testTagsCanBeAccessed() public function testTagEntriesCanBeStoredForever() { - $this->markTestSkippedWithPredisClusterConnection(); - Cache::store('redis')->clear(); Cache::store('redis')->tags(['people', 'author'])->forever('name', 'Sally'); @@ -274,8 +269,6 @@ public function testIncrementWithSerializationEnabled() public function testTagsCanBeFlushedWithLargeNumberOfKeys() { - $this->markTestSkippedWithPredisClusterConnection(); - Cache::store('redis')->clear(); $tags = ['large-test-'.time()]; @@ -297,12 +290,4 @@ public function testTagsCanBeFlushedWithLargeNumberOfKeys() $keyCount = Cache::store('redis')->connection()->keys('*'); $this->assertCount(0, $keyCount); } - - protected function markTestSkippedWithPredisClusterConnection() - { - $this->markTestSkippedWhen( - $this->app['redis']->connection() instanceof PredisClusterConnection, - 'This test currently fails on Predis Cluster connection', - ); - } }