From a85d5b01f7a5a16d656de36877a19975b825d5a3 Mon Sep 17 00:00:00 2001 From: Florent Olivaud Date: Tue, 20 Jun 2017 17:06:22 +0200 Subject: [PATCH] Fix Predis client cluster with pipeline --- src/Symfony/Component/Cache/Traits/RedisTrait.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index f28da3934662..b45d65adc853 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Traits; use Predis\Connection\Factory; +use Predis\Connection\Aggregate\ClusterInterface; use Predis\Connection\Aggregate\PredisCluster; use Predis\Connection\Aggregate\RedisCluster; use Predis\Response\Status; @@ -284,7 +285,7 @@ private function pipeline(\Closure $generator) { $ids = array(); - if ($this->redis instanceof \Predis\Client) { + if ($this->redis instanceof \Predis\Client && !$this->redis->getConnection() instanceof ClusterInterface) { $results = $this->redis->pipeline(function ($redis) use ($generator, &$ids) { foreach ($generator() as $command => $args) { call_user_func_array(array($redis, $command), $args); @@ -308,9 +309,10 @@ private function pipeline(\Closure $generator) foreach ($results as $k => list($h, $c)) { $results[$k] = $connections[$h][$c]; } - } elseif ($this->redis instanceof \RedisCluster) { - // phpredis doesn't support pipelining with RedisCluster + } elseif ($this->redis instanceof \RedisCluster || ($this->redis instanceof \Predis\Client && $this->redis->getConnection() instanceof ClusterInterface)) { + // phpredis & predis don't support pipelining with RedisCluster // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining + // see https://github.com/nrk/predis/issues/267#issuecomment-123781423 $results = array(); foreach ($generator() as $command => $args) { $results[] = call_user_func_array(array($this->redis, $command), $args);