mirror of
https://github.com/predis/predis.git
synced 2026-09-12 19:37:05 +00:00
Give up on some core reusing practices in favor of execution speed and memory usage.
This commit is contained in:
@@ -12,7 +12,7 @@ use Predis\Protocols\TextCommandSerializer;
|
||||
use Predis\Iterators\MultiBulkResponseSimple;
|
||||
|
||||
class StreamConnection extends ConnectionBase {
|
||||
private $_commandSerializer, $_mbiterable, $_throwErrors;
|
||||
private $_mbiterable, $_throwErrors;
|
||||
|
||||
public function __destruct() {
|
||||
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() {
|
||||
$parameters = $this->_params;
|
||||
$initializer = array($this, "{$parameters->scheme}StreamInitializer");
|
||||
@@ -180,7 +175,19 @@ class StreamConnection extends ConnectionBase {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user