Skip to content

Commit 82a26e0

Browse files
[12.x] Fixing RedisTaggedCache::flushValues with PredisClusterConnection (#57848)
* [12.x] unskip tests * [12.x] flushValues for PredisCluster in RedisTaggedCache * formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 3d5a2df commit 82a26e0

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/Illuminate/Cache/RedisTaggedCache.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,18 @@ protected function flushValues()
193193
->map(fn (string $key) => $this->store->getPrefix().$key)
194194
->chunk(1000);
195195

196+
$connection = $this->store->connection();
197+
196198
foreach ($entries as $cacheKeys) {
197-
$this->store->connection()->del(...$cacheKeys);
199+
if ($connection instanceof PredisClusterConnection) {
200+
$connection->pipeline(function ($connection) use ($cacheKeys) {
201+
foreach ($cacheKeys as $cacheKey) {
202+
$connection->del($cacheKey);
203+
}
204+
});
205+
} else {
206+
$connection->del(...$cacheKeys);
207+
}
198208
}
199209
}
200210

tests/Integration/Cache/RedisStoreTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Cache\RedisStore;
77
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
88
use Illuminate\Redis\Connections\PhpRedisClusterConnection;
9-
use Illuminate\Redis\Connections\PredisClusterConnection;
109
use Illuminate\Support\Facades\Cache;
1110
use Illuminate\Support\Sleep;
1211
use Mockery as m;
@@ -96,8 +95,6 @@ public function testItCanExpireWithZeroTTL()
9695

9796
public function testTagsCanBeAccessed()
9897
{
99-
$this->markTestSkippedWithPredisClusterConnection();
100-
10198
Cache::store('redis')->clear();
10299

103100
Cache::store('redis')->tags(['people', 'author'])->put('name', 'Sally', 5);
@@ -114,8 +111,6 @@ public function testTagsCanBeAccessed()
114111

115112
public function testTagEntriesCanBeStoredForever()
116113
{
117-
$this->markTestSkippedWithPredisClusterConnection();
118-
119114
Cache::store('redis')->clear();
120115

121116
Cache::store('redis')->tags(['people', 'author'])->forever('name', 'Sally');
@@ -274,8 +269,6 @@ public function testIncrementWithSerializationEnabled()
274269

275270
public function testTagsCanBeFlushedWithLargeNumberOfKeys()
276271
{
277-
$this->markTestSkippedWithPredisClusterConnection();
278-
279272
Cache::store('redis')->clear();
280273

281274
$tags = ['large-test-'.time()];
@@ -297,12 +290,4 @@ public function testTagsCanBeFlushedWithLargeNumberOfKeys()
297290
$keyCount = Cache::store('redis')->connection()->keys('*');
298291
$this->assertCount(0, $keyCount);
299292
}
300-
301-
protected function markTestSkippedWithPredisClusterConnection()
302-
{
303-
$this->markTestSkippedWhen(
304-
$this->app['redis']->connection() instanceof PredisClusterConnection,
305-
'This test currently fails on Predis Cluster connection',
306-
);
307-
}
308293
}

0 commit comments

Comments
 (0)