|
15 | 15 | use Predis\Connection\Aggregate\ClusterInterface;
|
16 | 16 | use Predis\Connection\Aggregate\RedisCluster;
|
17 | 17 | use Predis\Connection\Aggregate\ReplicationInterface;
|
| 18 | +use Predis\Connection\Cluster\ClusterInterface as Predis2ClusterInterface; |
| 19 | +use Predis\Connection\Cluster\RedisCluster as Predis2RedisCluster; |
18 | 20 | use Predis\Response\ErrorInterface;
|
19 | 21 | use Predis\Response\Status;
|
20 | 22 | use Relay\Relay;
|
@@ -376,7 +378,7 @@ protected function doFetch(array $ids): iterable
|
376 | 378 |
|
377 | 379 | $result = [];
|
378 | 380 |
|
379 |
| - if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) { |
| 381 | + if ($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) { |
380 | 382 | $values = $this->pipeline(function () use ($ids) {
|
381 | 383 | foreach ($ids as $id) {
|
382 | 384 | yield 'get' => [$id];
|
@@ -476,7 +478,7 @@ protected function doDelete(array $ids): bool
|
476 | 478 | return true;
|
477 | 479 | }
|
478 | 480 |
|
479 |
| - if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) { |
| 481 | + if ($this->redis instanceof \Predis\ClientInterface && ($this->redis->getConnection() instanceof ClusterInterface || $this->redis->getConnection() instanceof Predis2ClusterInterface)) { |
480 | 482 | static $del;
|
481 | 483 | $del ??= (class_exists(UNLINK::class) ? 'unlink' : 'del');
|
482 | 484 |
|
@@ -534,7 +536,7 @@ private function pipeline(\Closure $generator, object $redis = null): \Generator
|
534 | 536 | $ids = [];
|
535 | 537 | $redis ??= $this->redis;
|
536 | 538 |
|
537 |
| - if ($redis instanceof \RedisCluster || ($redis instanceof \Predis\ClientInterface && $redis->getConnection() instanceof RedisCluster)) { |
| 539 | + if ($redis instanceof \RedisCluster || ($redis instanceof \Predis\ClientInterface && ($redis->getConnection() instanceof RedisCluster || $redis->getConnection() instanceof Predis2RedisCluster))) { |
538 | 540 | // phpredis & predis don't support pipelining with RedisCluster
|
539 | 541 | // see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining
|
540 | 542 | // see https://github.com/nrk/predis/issues/267#issuecomment-123781423
|
@@ -596,7 +598,7 @@ private function getHosts(): array
|
596 | 598 | $hosts = [$this->redis];
|
597 | 599 | if ($this->redis instanceof \Predis\ClientInterface) {
|
598 | 600 | $connection = $this->redis->getConnection();
|
599 |
| - if ($connection instanceof ClusterInterface && $connection instanceof \Traversable) { |
| 601 | + if (($connection instanceof ClusterInterface || $connection instanceof Predis2ClusterInterface) && $connection instanceof \Traversable) { |
600 | 602 | $hosts = [];
|
601 | 603 | foreach ($connection as $c) {
|
602 | 604 | $hosts[] = new \Predis\Client($c);
|
|
0 commit comments