mirror of
https://github.com/predis/predis.git
synced 2026-09-12 19:37:05 +00:00
Refactored Client::executeCommand and introduced the new method Client::executeCommandOnShards which is useful to execute commands on all the connections registered in a ConnectionCluster instance.
This commit is contained in:
+21
-4
@@ -104,12 +104,29 @@ class Client {
|
||||
return $command;
|
||||
}
|
||||
|
||||
public function executeCommand(Command $command) {
|
||||
$this->_connection->writeCommand($command);
|
||||
private function executeCommandInternal(Connection $connection, Command $command) {
|
||||
$connection->writeCommand($command);
|
||||
if ($command->closesConnection()) {
|
||||
return $this->_connection->disconnect();
|
||||
return $connection->disconnect();
|
||||
}
|
||||
return $this->_connection->readResponse($command);
|
||||
return $connection->readResponse($command);
|
||||
}
|
||||
|
||||
public function executeCommand(Command $command) {
|
||||
return self::executeCommandInternal($this->_connection, $command);
|
||||
}
|
||||
|
||||
public function executeCommandOnShards(Command $command) {
|
||||
$replies = array();
|
||||
if (is_a($this->_connection, '\Predis\ConnectionCluster')) {
|
||||
foreach($this->_connection as $connection) {
|
||||
$replies[] = self::executeCommandInternal($connection, $command);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$replies[] = self::executeCommandInternal($this->_connection, $command);
|
||||
}
|
||||
return $replies;
|
||||
}
|
||||
|
||||
public function rawCommand($rawCommandData, $closesConnection = false) {
|
||||
|
||||
Reference in New Issue
Block a user