コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function serialize(ICommand $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";
     }
     return $buffer;
 }
コード例 #2
0
 /**
  * Checks if a SORT command is a readable operation by parsing the arguments
  * array of the specified commad instance.
  *
  * @param ICommand $command Instance of Redis command.
  * @return Boolean
  */
 private function isSortReadOnly(ICommand $command)
 {
     $arguments = $command->getArguments();
     return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE';
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function writeCommand(ICommand $command)
 {
     $cmdargs = $command->getArguments();
     array_unshift($cmdargs, $command->getId());
     $this->write(phpiredis_format_command($cmdargs));
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function writeCommand(ICommand $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->writeBytes($buffer);
 }