Эх сурвалжийг харах

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

Daniele Alessandri 15 жил өмнө
parent
commit
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) {
     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) {
     public function getConnectionById($id = null) {