Add new command class useful to execute "raw" Redis commands.

By raw we mean that input arguments are not filtered and responses are
not parsed, which means arguments must follow the command signature as
defined by Redis and complex responses are left untouched.

When instantiating an instance of `Predis\Command\RawCommand` you must
pass at least the command ID. You can pass further arguments in the
array or you can just set them later with `RawCommand::setArguments()`
but you cannot modify the command ID once instantiated.

  $command = new Predis\Command\RawCommand(['SET', 'foo', 'bar']);
  $response = $client->executeCommand($command);

While higher level abstractions built upon `Predis\Client` should just
use commands created by the profile in use, inner parts of the library
might use raw commands to provide certain functionalities making sure
that input and output of commands are always consistent, independent
of the profile.
This commit is contained in:
Daniele Alessandri
2013-11-30 13:15:12 +01:00
parent bb4b8c3c35
commit cf581a3b49
4 changed files with 306 additions and 17 deletions
@@ -13,7 +13,7 @@ namespace Predis\Command\Processor;
use stdClass;
use PHPUnit_Framework_TestCase as StandardTestCase;
use Predis\Command\Command;
use Predis\Command\RawCommand;
/**
*
@@ -321,7 +321,7 @@ class KeyPrefixProcessorTest extends StandardTestCase
public function getCommandInstance($commandID, array $arguments)
{
$command = new DummyCommand($commandID);
$command = new RawCommand(array($commandID));
$command->setRawArguments($arguments);
return $command;
@@ -803,18 +803,3 @@ class KeyPrefixProcessorTest extends StandardTestCase
);
}
}
class DummyCommand extends Command
{
protected $commandID;
public function __construct($commandID)
{
$this->commandID = $commandID;
}
public function getId()
{
return $this->commandID;
}
}