8000 Fix Predis client cluster with pipeline · symfony/symfony@802f95f · GitHub
[go: up one dir, main page]

Skip to content

Commit 802f95f

Browse files
committed
Fix Predis client cluster with pipeline
1 parent 3bbb657 commit 802f95f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Cache\Traits;
1313

1414
use Predis\Connection\Factory;
15+
use Predis\Connection\Aggregate\ClusterInterface;
1516
use Predis\Connection\Aggregate\PredisCluster;
1617
use Predis\Connection\Aggregate\RedisCluster;
1718
use Predis\Response\Status;
@@ -284,7 +285,7 @@ private function pipeline(\Closure $generator)
284285
{
285286
$ids = array();
286287

287-
if ($this->redis instanceof \Predis\Client) {
288+
if ($this->redis instanceof \Predis\Client && !($this->redis->getConnection() instanceof ClusterInterface)) {
288289
$results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) {
289290
foreach ($generator() as $command => $args) {
290291
call_user_func_array(array($redis, $command), $args);
@@ -308,9 +309,12 @@ private function pipeline(\Closure $generator)
308309
foreach ($results as $k => list($h, $c)) {
309310
$results[$k] = $connections[$h][$c];
310311
}
311-
} elseif ($this->redis instanceof \RedisCluster) {
312-
// phpredis doesn't support pipelining with RedisCluster
312+
} elseif ($this->redis instanceof \RedisCluster || (
313+
$this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface
314+
)) {
315+
// phpredis & predis doesn't support pipelining with RedisCluster
313316
// see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining
317+
// see https://github.com/nrk/predis/issues/267#issuecomment-123781423
314318
$results = array();
315319
foreach ($generator() as $command => $args) {
316320
$results[] = call_user_func_array(array($this->redis, $command), $args);

0 commit comments

Comments
 (0)
0