当前位置: 首页>>代码示例>>PHP>>正文


PHP Command\CommandInterface类代码示例

本文整理汇总了PHP中Predis\Command\CommandInterface的典型用法代码示例。如果您正苦于以下问题:PHP CommandInterface类的具体用法?PHP CommandInterface怎么用?PHP CommandInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeCommand

 /**
  * {@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]);
 }
开发者ID:xzander,项目名称:predis-async,代码行数:12,代码来源:StreamConnection.php

示例2: executeCommand

 /**
  * {@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]);
 }
开发者ID:xzander,项目名称:predis-async,代码行数:13,代码来源:PhpiredisStreamConnection.php

示例3: onResponseObject

 /**
  * Handles a response object.
  *
  * @param  ConnectionInterface     $connection
  * @param  CommandInterface        $command
  * @param  ResponseObjectInterface $response
  * @return mixed
  */
 protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response)
 {
     if ($response instanceof ResponseErrorInterface) {
         return $this->onResponseError($connection, $response);
     }
     if ($response instanceof Iterator) {
         return $command->parseResponse(iterator_to_array($response));
     }
     return $response;
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:18,代码来源:StandardExecutor.php

示例4: __construct

 /**
  * @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;
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:14,代码来源:RedisCommandConstraint.php

示例5: storeDebug

 private function storeDebug(CommandInterface $command, $direction)
 {
     $firtsArg = $command->getArgument(0);
     $timestamp = round(microtime(true) - $this->tstart, 4);
     $debug = $command->getId();
     $debug .= isset($firtsArg) ? " {$firtsArg} " : ' ';
     $debug .= "{$direction} {$this}";
     $debug .= " [{$timestamp}s]";
     $this->debugBuffer[] = $debug;
 }
开发者ID:flachesis,项目名称:predis,代码行数:10,代码来源:debuggable_connection.php

示例6: serialize

 /**
  * {@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;
 }
开发者ID:cdandy,项目名称:code-lib,代码行数:16,代码来源:RequestSerializer.php

示例7: serialize

 /**
  * {@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;
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:17,代码来源:TextCommandSerializer.php

示例8: writeCommand

 /**
  * {@inheritdoc}
  */
 public function writeCommand(CommandInterface $command)
 {
     $cmdargs = $command->getArguments();
     array_unshift($cmdargs, $command->getId());
     $this->write(phpiredis_format_command($cmdargs));
 }
开发者ID:surjit,项目名称:node-redis-php-chat-app,代码行数:9,代码来源:PhpiredisConnection.php

示例9: isSortReadOnly

 /**
  * 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';
 }
开发者ID:sohel4r,项目名称:wordpress_4_1_1,代码行数:13,代码来源:predis.php

示例10: process

 /**
  * {@inheritdoc}
  */
 public function process(CommandInterface $command)
 {
     if ($command instanceof PrefixableCommandInterface && $command->getArguments()) {
         $command->prefixKeys($this->prefix);
     }
 }
开发者ID:kchhainarong,项目名称:chantuchP,代码行数:9,代码来源:KeyPrefixProcessor.php

示例11: getHash

 /**
  * {@inheritdoc}
  */
 public function getHash(CommandInterface $command)
 {
     $hash = $command->getHash();
     if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) {
         if (null !== ($key = call_user_func($this->commands[$cmdID], $command))) {
             $hash = $this->hashGenerator->hash($key);
             $command->setHash($hash);
         }
     }
     return $hash;
 }
开发者ID:rubensayshi,项目名称:predis,代码行数:14,代码来源:RedisClusterHashStrategy.php

示例12: getCommandId

 /**
  * Checks if the specified command is supported by this connection class.
  *
  * @param CommandInterface $command Command instance.
  *
  * @return string
  *
  * @throws NotSupportedException
  */
 protected function getCommandId(CommandInterface $command)
 {
     switch ($commandID = $command->getId()) {
         case 'AUTH':
         case 'SELECT':
         case 'MULTI':
         case 'EXEC':
         case 'WATCH':
         case 'UNWATCH':
         case 'DISCARD':
         case 'MONITOR':
             throw new NotSupportedException("Command '{$commandID}' is not allowed by Webdis.");
         default:
             return $commandID;
     }
 }
开发者ID:creativeprogramming,项目名称:NodeJS-Helper,代码行数:25,代码来源:WebdisConnection.php

示例13: migrate

 /**
  * 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);
     }
 }
开发者ID:flachesis,项目名称:predis,代码行数:13,代码来源:KeyPrefixProcessor.php

示例14: onErrorResponse

 /**
  * Handles -ERR responses returned by Redis.
  *
  * @param CommandInterface       $command  Redis command that generated the error.
  * @param ErrorResponseInterface $response Instance of the error response.
  *
  * @throws ServerException
  * @return mixed
  *
  */
 protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response)
 {
     if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
         $eval = $this->createCommand('EVAL');
         $eval->setRawArguments($command->getEvalArguments());
         $response = $this->executeCommand($eval);
         if (!$response instanceof ResponseInterface) {
             $response = $command->parseResponse($response);
         }
         return $response;
     }
     if ($this->options->exceptions) {
         throw new ServerException($response->getMessage());
     }
     return $response;
 }
开发者ID:sandeeprajoria,项目名称:predis,代码行数:26,代码来源:Client.php

示例15: getTestCaseBuffer

    protected function getTestCaseBuffer(CommandInterface $instance)
    {
        $id = $instance->getId();
        $fqn = get_class($instance);
        $fqnParts = explode('\\', $fqn);
        $class = array_pop($fqnParts) . "Test";
        $realm = $this->getTestRealm();
        $buffer = <<<PHP
<?php

/*
 * This file is part of the Predis package.
 *
 * (c) Daniele Alessandri <suppakilla@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Predis\\Command;

use \\PHPUnit_Framework_TestCase as StandardTestCase;

/**
 * @group commands
 * @group realm-{$realm}
 */
class {$class} extends CommandTestCase
{
    /**
     * {@inheritdoc}
     */
    protected function getExpectedCommand()
    {
        return '{$fqn}';
    }

    /**
     * {@inheritdoc}
     */
    protected function getExpectedId()
    {
        return '{$id}';
    }

    /**
     * @group disconnected
     */
    public function testFilterArguments()
    {
        \$this->markTestIncomplete('This test has not been implemented yet.');

        \$arguments = array(/* add arguments */);
        \$expected = array(/* add arguments */);

        \$command = \$this->getCommand();
        \$command->setArguments(\$arguments);

        \$this->assertSame(\$expected, \$command->getArguments());
    }

    /**
     * @group disconnected
     */
    public function testParseResponse()
    {
        \$this->markTestIncomplete('This test has not been implemented yet.');

        \$raw = null;
        \$expected = null;

        \$command = \$this->getCommand();

        \$this->assertSame(\$expected, \$command->parseResponse(\$raw));
    }

PHP;
        if ($instance instanceof PrefixableCommandInterface) {
            $buffer .= <<<PHP

    /**
     * @group disconnected
     */
    public function testPrefixKeys()
    {
        \$this->markTestIncomplete('This test has not been implemented yet.');

        \$arguments = array(/* add arguments */);
        \$expected = array(/* add arguments */);

        \$command = \$this->getCommandWithArgumentsArray(\$arguments);
        \$command->prefixKeys('prefix:');

        \$this->assertSame(\$expected, \$command->getArguments());
    }

    /**
     * @group disconnected
     */
    public function testPrefixKeysIgnoredOnEmptyArguments()
//.........这里部分代码省略.........
开发者ID:Thomvh,项目名称:turbine,代码行数:101,代码来源:generate-command-test.php


注:本文中的Predis\Command\CommandInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。