Browse Source

Added Predis\ClientContextInterface.

This interface replaces Predis\ExecutableContextInterface and it is
used by client-side contexts such as pipelines or transactions.
Daniele Alessandri 10 years ago
parent
commit
38710cd69b

+ 4 - 0
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)

+ 48 - 0
src/ClientContextInterface.php

@@ -0,0 +1,48 @@
+<?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;
+
+use Predis\Command\CommandInterface;
+
+/**
+ * Interface defining a client-side context such as a pipeline or transaction.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+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);
+}

+ 0 - 29
src/ExecutableContextInterface.php

@@ -1,29 +0,0 @@
-<?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;
-
-/**
- * Defines the interface of a basic client object or abstraction that can send
- * commands to Redis.
- *
- * @author Daniele Alessandri <suppakilla@gmail.com>
- */
-interface ExecutableContextInterface
-{
-    /**
-     * Starts the execution of the context.
-     *
-     * @param  mixed $callable Optional callback for execution.
-     * @return array
-     */
-    public function execute($callable = null);
-}

+ 2 - 2
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 <suppakilla@gmail.com>
  */
-class Pipeline implements ExecutableContextInterface
+class Pipeline implements ClientContextInterface
 {
     private $client;
     private $pipeline;

+ 2 - 2
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 <suppakilla@gmail.com>
  */
-class MultiExec implements ExecutableContextInterface
+class MultiExec implements ClientContextInterface
 {
     private $state;