|
@@ -12,7 +12,7 @@ use Predis\Protocols\TextCommandSerializer;
|
|
use Predis\Iterators\MultiBulkResponseSimple;
|
|
use Predis\Iterators\MultiBulkResponseSimple;
|
|
|
|
|
|
class StreamConnection extends ConnectionBase {
|
|
class StreamConnection extends ConnectionBase {
|
|
- private $_commandSerializer, $_mbiterable, $_throwErrors;
|
|
|
|
|
|
+ private $_mbiterable, $_throwErrors;
|
|
|
|
|
|
public function __destruct() {
|
|
public function __destruct() {
|
|
if (!$this->_params->connection_persistent) {
|
|
if (!$this->_params->connection_persistent) {
|
|
@@ -20,11 +20,6 @@ class StreamConnection extends ConnectionBase {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- protected function initializeProtocol(ConnectionParameters $parameters) {
|
|
|
|
- $this->_commandSerializer = new TextCommandSerializer();
|
|
|
|
- parent::initializeProtocol($parameters);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
protected function createResource() {
|
|
protected function createResource() {
|
|
$parameters = $this->_params;
|
|
$parameters = $this->_params;
|
|
$initializer = array($this, "{$parameters->scheme}StreamInitializer");
|
|
$initializer = array($this, "{$parameters->scheme}StreamInitializer");
|
|
@@ -180,7 +175,19 @@ class StreamConnection extends ConnectionBase {
|
|
}
|
|
}
|
|
|
|
|
|
public function writeCommand(ICommand $command) {
|
|
public function writeCommand(ICommand $command) {
|
|
- $this->write($this->_commandSerializer->serialize($command));
|
|
|
|
|
|
+ $commandId = $command->getId();
|
|
|
|
+ $arguments = $command->getArguments();
|
|
|
|
+
|
|
|
|
+ $cmdlen = strlen($commandId);
|
|
|
|
+ $reqlen = count($arguments) + 1;
|
|
|
|
+
|
|
|
|
+ $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n";
|
|
|
|
+ for ($i = 0; $i < $reqlen - 1; $i++) {
|
|
|
|
+ $argument = $arguments[$i];
|
|
|
|
+ $arglen = strlen($argument);
|
|
|
|
+ $buffer .= "\${$arglen}\r\n{$argument}\r\n";
|
|
|
|
+ }
|
|
|
|
+ $this->write($buffer);
|
|
}
|
|
}
|
|
|
|
|
|
public function readResponse(ICommand $command) {
|
|
public function readResponse(ICommand $command) {
|