mirror of
https://github.com/predis/predis.git
synced 2026-10-06 11:59:30 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user