File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
src/Symfony/Component/Cache Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Predis \Connection \Aggregate \ClusterInterface ;
15
15
use Predis \Connection \Aggregate \PredisCluster ;
16
+ use Predis \Connection \Aggregate \ReplicationInterface ;
16
17
use Predis \Response \Status ;
17
18
use Symfony \Component \Cache \Exception \InvalidArgumentException ;
18
19
use Symfony \Component \Cache \Exception \LogicException ;
@@ -278,7 +279,14 @@ private function getRedisEvictionPolicy(): string
278
279
return $ this ->redisEvictionPolicy ;
279
280
}
280
281
281
- foreach ($ this ->getHosts () as $ host ) {
282
+ $ hosts = $ this ->getHosts ();
283
+ $ host = reset ($ hosts );
284
+ if ($ host instanceof \Predis \Client && $ host ->getConnection () instanceof ReplicationInterface) {
285
+ // Predis supports info command only on the master in replication environments
286
+ $ hosts = [$ host ->getClientFor ('master ' )];
287
+ }
288
+
289
+ foreach ($ hosts as $ host ) {
282
290
$ info = $ host ->info ('Memory ' );
283
291
$ info = $ info ['Memory ' ] ?? $ info ;
284
292
Original file line number Diff line number Diff line change 13
13
14
14
use Predis \Connection \Aggregate \ClusterInterface ;
15
15
use Predis \Connection \Aggregate \RedisCluster ;
16
+ use Predis \Connection \Aggregate \ReplicationInterface ;
16
17
use Predis \Response \Status ;
17
18
use Symfony \Component \Cache \Exception \CacheException ;
18
19
use Symfony \Component \Cache \Exception \InvalidArgumentException ;
@@ -367,7 +368,14 @@ protected function doClear($namespace)
367
368
$ evalArgs = [[$ namespace ], 0 ];
368
369
}
369
370
370
- foreach ($ this ->getHosts () as $ host ) {
371
+ $ hosts = $ this ->getHosts ();
372
+ $ host = reset ($ hosts );
373
+ if ($ host instanceof \Predis \Client && $ host ->getConnection () instanceof ReplicationInterface) {
374
+ // Predis supports info command only on the master in replication environments
375
+ $ hosts = [$ host ->getClientFor ('master ' )];
376
+ }
377
+
378
+ foreach ($ hosts as $ host ) {
371
379
if (!isset ($ namespace [0 ])) {
372
380
$ cleared = $ host ->flushDb () && $ cleared ;
373
381
continue ;
You can’t perform that action at this time.
0 commit comments