diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a72ac2..0f40fa1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,10 @@ v1.0.0 (201x-xx-xx) shorter `Predis\Command\Processor\ProcessorInterface`. Also removed interface for chain processors since it is basically useless. +- Renamed `Predis\ExecutableContextInterface` to `Predis\ClientContextInterface` + and augmented it with a couple of required methods since this interface is no + more comparable to a basic client as it could be misleading. + - The `Predis\Option` namespace is now known as `Predis\Configuration` and have a fully-reworked `Options` class with the ability to lazily initialize values using objects that responds to `__invoke()` (not all the kinds of callables) diff --git a/src/ClientContextInterface.php b/src/ClientContextInterface.php new file mode 100644 index 00000000..fde559db --- /dev/null +++ b/src/ClientContextInterface.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use Predis\Command\CommandInterface; + +/** + * Interface defining a client-side context such as a pipeline or transaction. + * + * @author Daniele Alessandri + */ +interface ClientContextInterface +{ + + /** + * Sends the specified command instance to Redis. + * + * @param CommandInterface $command Command instance. + * @return mixed + */ + public function executeCommand(CommandInterface $command); + + /** + * Sends the specified command with its arguments to Redis. + * + * @param string $commandID Command ID. + * @param array $arguments Arguments for the command. + * @return mixed + */ + public function __call($method, $arguments); + + /** + * Starts the execution of the context. + * + * @param mixed $callable Optional callback for execution. + * @return array + */ + public function execute($callable = null); +} diff --git a/src/ExecutableContextInterface.php b/src/ExecutableContextInterface.php deleted file mode 100644 index b4443b4e..00000000 --- a/src/ExecutableContextInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Defines the interface of a basic client object or abstraction that can send - * commands to Redis. - * - * @author Daniele Alessandri - */ -interface ExecutableContextInterface -{ - /** - * Starts the execution of the context. - * - * @param mixed $callable Optional callback for execution. - * @return array - */ - public function execute($callable = null); -} diff --git a/src/Pipeline/Pipeline.php b/src/Pipeline/Pipeline.php index d07951a8..86461616 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -14,9 +14,9 @@ namespace Predis\Pipeline; use Exception; use InvalidArgumentException; use SplQueue; +use Predis\ClientContextInterface; use Predis\ClientException; use Predis\ClientInterface; -use Predis\ExecutableContextInterface; use Predis\Command\CommandInterface; use Predis\Connection\ConnectionInterface; use Predis\Connection\Aggregate\ReplicationInterface; @@ -30,7 +30,7 @@ use Predis\Response\ServerException; * * @author Daniele Alessandri */ -class Pipeline implements ExecutableContextInterface +class Pipeline implements ClientContextInterface { private $client; private $pipeline; diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index b22f51ca..d4bf789e 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -14,10 +14,10 @@ namespace Predis\Transaction; use Exception; use InvalidArgumentException; use SplQueue; +use Predis\ClientContextInterface; use Predis\ClientException; use Predis\ClientInterface; use Predis\CommunicationException; -use Predis\ExecutableContextInterface; use Predis\NotSupportedException; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ServerException; @@ -31,7 +31,7 @@ use Predis\Protocol\ProtocolException; * * @author Daniele Alessandri */ -class MultiExec implements ExecutableContextInterface +class MultiExec implements ClientContextInterface { private $state;