瀏覽代碼

Expose the command hash strategy from the predis cluster class.

This will be useful to add, remove or change the handler used to
extract, validate and hash the keys of each command instance.
Daniele Alessandri 13 年之前
父節點
當前提交
f2d92f1e29
共有 2 個文件被更改,包括 20 次插入0 次删除
  1. 11 0
      lib/Predis/Connection/PredisCluster.php
  2. 9 0
      tests/Predis/Connection/PredisClusterTest.php

+ 11 - 0
lib/Predis/Connection/PredisCluster.php

@@ -167,6 +167,17 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \
         return $node;
     }
 
+    /**
+     * Returns the underlying command hash strategy used to hash
+     * commands by their keys.
+     *
+     * @return CommandHashStrategy
+     */
+    public function getCommandHashStrategy()
+    {
+        return $this->cmdHasher;
+    }
+
     /**
      * {@inheritdoc}
      */

+ 9 - 0
tests/Predis/Connection/PredisClusterTest.php

@@ -21,6 +21,15 @@ use Predis\Profile\ServerProfile;
  */
 class PredisClusterTest extends StandardTestCase
 {
+    /**
+     * @group disconnected
+     */
+    public function testExposesCommandHashStrategy()
+    {
+        $cluster = new PredisCluster();
+        $this->assertInstanceOf('Predis\Command\Hash\CommandHashStrategy', $cluster->getCommandHashStrategy());
+    }
+
     /**
      * @group disconnected
      */