getArguments() public method

Gets the arguments of the command.
public getArguments ( ) : array
return array
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function executeCommand(CommandInterface $command, callable $callback)
 {
     if ($this->buffer->isEmpty() && ($stream = $this->getResource())) {
         $this->loop->addWriteStream($stream, $this->writableCallback);
     }
     $request = $this->serializer->getRequestMessage($command->getId(), $command->getArguments());
     $this->buffer->append($request);
     $this->commands->enqueue([$command, $callback]);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function executeCommand(CommandInterface $command, callable $callback)
 {
     if ($this->buffer->isEmpty() && ($stream = $this->getResource())) {
         $this->loop->addWriteStream($stream, $this->writableCallback);
     }
     $cmdargs = $command->getArguments();
     array_unshift($cmdargs, $command->getId());
     $this->buffer->append(phpiredis_format_command($cmdargs));
     $this->commands->enqueue([$command, $callback]);
 }
コード例 #3
0
 /**
  * @param string|CommandInterface $command   Expected command ID or instance.
  * @param array                   $arguments Expected command arguments.
  */
 public function __construct($command = null, array $arguments = null)
 {
     if ($command instanceof CommandInterface) {
         $this->commandID = strtoupper($command->getId());
         $this->arguments = $arguments ?: $command->getArguments();
     } else {
         $this->commandID = strtoupper($command);
         $this->arguments = $arguments;
     }
 }
コード例 #4
0
ファイル: RequestSerializer.php プロジェクト: cdandy/code-lib
 /**
  * {@inheritdoc}
  */
 public function serialize(CommandInterface $command)
 {
     $commandID = $command->getId();
     $arguments = $command->getArguments();
     $cmdlen = strlen($commandID);
     $reqlen = count($arguments) + 1;
     $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandID}\r\n";
     foreach ($arguments as $argument) {
         $arglen = strlen($argument);
         $buffer .= "\${$arglen}\r\n{$argument}\r\n";
     }
     return $buffer;
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function serialize(CommandInterface $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, $reqlen--; $i < $reqlen; $i++) {
         $argument = $arguments[$i];
         $arglen = strlen($argument);
         $buffer .= "\${$arglen}\r\n{$argument}\r\n";
     }
     return $buffer;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function writeCommand(CommandInterface $command)
 {
     $cmdargs = $command->getArguments();
     array_unshift($cmdargs, $command->getId());
     $this->write(phpiredis_format_command($cmdargs));
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function process(CommandInterface $command)
 {
     if ($command instanceof PrefixableCommandInterface && $command->getArguments()) {
         $command->prefixKeys($this->prefix);
     }
 }
コード例 #8
0
 /**
  * Applies the specified prefix to the key of a MIGRATE command.
  *
  * @param CommandInterface $command Command instance.
  * @param string           $prefix  Prefix string.
  */
 public static function migrate(CommandInterface $command, $prefix)
 {
     if ($arguments = $command->getArguments()) {
         $arguments[2] = "{$prefix}{$arguments[2]}";
         $command->setRawArguments($arguments);
     }
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function writeCommand(CommandInterface $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);
 }
コード例 #10
0
 /**
  * Extracts the key from ZINTERSTORE and ZUNIONSTORE commands.
  *
  * @param CommandInterface $command Command instance.
  * @return string
  */
 protected function getKeyFromZsetAggregationCommands(CommandInterface $command)
 {
     $arguments = $command->getArguments();
     $keys = array_merge(array($arguments[0]), array_slice($arguments, 2, $arguments[1]));
     if ($this->checkSameHashForKeys($keys)) {
         return $arguments[0];
     }
 }
コード例 #11
0
 private function commandToString(CommandInterface $command)
 {
     return array_reduce($command->getArguments(), array($this, 'toStringArgumentReducer'), $command->getId());
 }
コード例 #12
0
ファイル: KeyPrefixProcessor.php プロジェクト: goodww1/predis
 /**
  * Applies the specified prefix to the keys of Z[INTERSECTION|UNION]STORE.
  *
  * @param CommandInterface $command Command instance.
  * @param string           $prefix  Prefix string.
  */
 public static function zsetStore(CommandInterface $command, $prefix)
 {
     if ($arguments = $command->getArguments()) {
         $arguments[0] = "{$prefix}{$arguments[0]}";
         $length = (int) $arguments[1] + 2;
         for ($i = 2; $i < $length; $i++) {
             $arguments[$i] = "{$prefix}{$arguments[$i]}";
         }
         $command->setRawArguments($arguments);
     }
 }
コード例 #13
0
 /**
  * Checks if a GEORADIUS command is a readable operation by parsing the
  * arguments array of the specified commad instance.
  *
  * @param CommandInterface $command Command instance.
  *
  * @return bool
  */
 protected function isGeoradiusReadOnly(CommandInterface $command)
 {
     $arguments = $command->getArguments();
     $argc = count($arguments);
     $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
     if ($argc > $startIndex) {
         for ($i = $startIndex; $i < $argc; ++$i) {
             $argument = strtoupper($arguments[$i]);
             if ($argument === 'STORE' || $argument === 'STOREDIST') {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #14
0
 /**
  * Extracts the key from BLPOP and BRPOP commands ensuring that only one key
  * is actually specified to comply with redis-cluster.
  *
  * @param CommandInterface $command Command instance.
  * @return string
  */
 protected function getKeyFromBlockingListCommands(CommandInterface $command)
 {
     $arguments = $command->getArguments();
     if (count($arguments) === 2) {
         return $arguments[0];
     }
 }
コード例 #15
0
ファイル: predis.php プロジェクト: sohel4r/wordpress_4_1_1
 /**
  * Checks if a SORT command is a readable operation by parsing the arguments
  * array of the specified commad instance.
  *
  * @param CommandInterface $command Command instance.
  *
  * @return bool
  */
 protected function isSortReadOnly(CommandInterface $command)
 {
     $arguments = $command->getArguments();
     return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE';
 }
コード例 #16
0
 /**
  * Extracts the key from EVAL and EVALSHA commands.
  *
  * @param CommandInterface $command Command instance.
  * @return string
  */
 protected function getKeyFromScriptingCommands(CommandInterface $command)
 {
     if ($command instanceof ScriptedCommand) {
         $keys = $command->getKeys();
     } else {
         $keys = array_slice($args = $command->getArguments(), 2, $args[1]);
     }
     if ($keys && $this->checkSameHashForKeys($keys)) {
         return $keys[0];
     }
 }
コード例 #17
0
 /**
  * Extracts the key from EVAL and EVALSHA commands.
  *
  * @param  CommandInterface $command Command instance.
  * @return string
  */
 protected function getKeyFromScriptingCommands(CommandInterface $command)
 {
     if ($command instanceof ScriptedCommand) {
         $keys = $command->getKeys();
     } else {
         $keys = array_slice($args = $command->getArguments(), 2, $args[1]);
     }
     if (count($keys) === 1) {
         return $keys[0];
     }
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 public function writeRequest(CommandInterface $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, $reqlen--; $i < $reqlen; ++$i) {
         $argument = $arguments[$i];
         $arglen = strlen($argument);
         $buffer .= "\${$arglen}\r\n{$argument}\r\n";
     }
     $this->write($buffer);
 }
コード例 #19
0
 /**
  * Applies the specified prefix to the key of a GEORADIUS command.
  *
  * @param CommandInterface $command Command instance.
  * @param string           $prefix  Prefix string.
  */
 public static function georadius(CommandInterface $command, $prefix)
 {
     if ($arguments = $command->getArguments()) {
         $arguments[0] = "{$prefix}{$arguments[0]}";
         $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;
         if (($count = count($arguments)) > $startIndex) {
             for ($i = $startIndex; $i < $count; ++$i) {
                 switch (strtoupper($arguments[$i])) {
                     case 'STORE':
                     case 'STOREDIST':
                         $arguments[$i] = "{$prefix}{$arguments[++$i]}";
                         break;
                 }
             }
         }
         $command->setRawArguments($arguments);
     }
 }