From e89f5cbc3918c7c76884ee221dd3ef32bd7d9d1f Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Mon, 21 Jul 2014 11:11:52 +0200 Subject: [PATCH] Add method to get connection factory from redis-cluster connection. --- src/Connection/Aggregate/RedisCluster.php | 11 +++++++++++ .../Predis/Connection/Aggregate/RedisClusterTest.php | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Connection/Aggregate/RedisCluster.php b/src/Connection/Aggregate/RedisCluster.php index 47885a6e..03150b1c 100644 --- a/src/Connection/Aggregate/RedisCluster.php +++ b/src/Connection/Aggregate/RedisCluster.php @@ -497,6 +497,17 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable return $this->strategy; } + /** + * Returns the underlying connection factory used to create new connection + * instances to Redis nodes indicated by redis-cluster. + * + * @return FactoryInterface + */ + public function getConnectionFactory() + { + return $this->connections; + } + /** * Enables automatic fetching of the current slots map from one of the nodes * using the CLUSTER NODES command. This option is disabled by default but diff --git a/tests/Predis/Connection/Aggregate/RedisClusterTest.php b/tests/Predis/Connection/Aggregate/RedisClusterTest.php index d10720b7..28d7fd95 100644 --- a/tests/Predis/Connection/Aggregate/RedisClusterTest.php +++ b/tests/Predis/Connection/Aggregate/RedisClusterTest.php @@ -22,6 +22,17 @@ use Predis\Response; */ class RedisClusterTest extends PredisTestCase { + /** + * @group disconnected + */ + public function testAcceptsCustomConnectionFactory() + { + $factory = $this->getMock('Predis\Connection\FactoryInterface'); + $cluster = new RedisCluster($factory); + + $this->assertSame($factory, $cluster->getConnectionFactory()); + } + /** * @group disconnected */