ソースを参照

When using a ConnectionCluster (sharding data over multiple servers), disallow sending commands that cannot be hashed by a key argument.

Daniele Alessandri 15 年 前
コミット
b1edc31af3
1 ファイル変更6 行追加3 行削除
  1. 6 3
      lib/Predis.php

+ 6 - 3
lib/Predis.php

@@ -786,9 +786,12 @@ class ConnectionCluster implements IConnection, \IteratorAggregate {
     }
 
     private function getConnection(Command $command) {
-        return $command->canBeHashed() 
-            ? $this->getConnectionFromRing($command) 
-            : $this->getConnectionById(0);
+        if ($command->canBeHashed() === false) {
+            throw new ClientException(
+                sprintf("Cannot send '%s' commands to a cluster of connections.", $command->getCommandId())
+            );
+        }
+        return $this->getConnectionFromRing($command);
     }
 
     public function getConnectionById($id = null) {