Skip to content

Commit 5e417e9

Browse files
[12.x] Fixing MemoizedStore with Redis Cluster (#57828)
* [12.x] replace flushAll with flushDb in MemoizedStoreTest * [12.x] many for RedisStore * Update RedisStore.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent af844dd commit 5e417e9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/Illuminate/Cache/RedisStore.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class RedisStore extends TaggableStore implements LockProvider
1515
{
1616
use RetrievesMultipleKeys {
17+
many as private manyAlias;
1718
putMany as private putManyAlias;
1819
}
1920

@@ -92,6 +93,11 @@ public function many(array $keys)
9293

9394
$connection = $this->connection();
9495

96+
// PredisClusterConnection does not support reading multiple values if the keys hash differently...
97+
if ($connection instanceof PredisClusterConnection) {
98+
return $this->manyAlias($keys);
99+
}
100+
95101
$values = $connection->mget(array_map(function ($key) {
96102
return $this->prefix.$key;
97103
}, $keys));

tests/Integration/Cache/MemoizedStoreTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
use Illuminate\Cache\Events\WritingKey;
1414
use Illuminate\Contracts\Cache\Store;
1515
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
16-
use Illuminate\Redis\Connections\PhpRedisClusterConnection;
17-
use Illuminate\Redis\Connections\PredisClusterConnection;
1816
use Illuminate\Support\Facades\Cache;
1917
use Illuminate\Support\Facades\Config;
2018
use Illuminate\Support\Facades\Event;
@@ -33,14 +31,9 @@ protected function setUp(): void
3331

3432
$this->setUpRedis();
3533

36-
$connection = $this->app['redis']->connection();
37-
$this->markTestSkippedWhen(
38-
$connection instanceof PhpRedisClusterConnection || $connection instanceof PredisClusterConnection,
39-
'flushAll and many currently not supported for Redis Cluster connections',
40-
);
41-
4234
Config::set('cache.default', 'redis');
43-
Redis::flushAll();
35+
Redis::connection(Config::get('cache.stores.redis.connection'))->flushDb();
36+
Redis::connection(Config::get('cache.stores.redis.lock_connection'))->flushDb();
4437
}
4538

4639
protected function tearDown(): void

0 commit comments

Comments
 (0)