mirror of
https://github.com/predis/predis.git
synced 2026-09-16 05:17:02 +00:00
Add some supported options to Predis\Client::pipeline().
Only two options available for now, used to specify which kind of
pipeline object the client should use or return:
- "atomic": returns a pipeline wrapped in a MULTI / EXEC transaction
(class: Predis\Pipeline\Atomic).
- "fire-and-forget": returns a pipeline that does not read back
responses from the server (class: Predis\Pipeline\FireAndForget).
We might add more options in the future.
This commit is contained in:
+7
-1
@@ -18,7 +18,13 @@ v0.9.0 (201x-xx-xx)
|
||||
even for custom options defined by the user.
|
||||
|
||||
- Removed pipeline executors, now command pipelines can be easily customized by
|
||||
extending the standard `Predis\Pipeline\Pipeline` class.
|
||||
extending the standard `Predis\Pipeline\Pipeline` class. Accepted options when
|
||||
creating a pipeline using `Predis\Client::pipeline()` are:
|
||||
|
||||
- `atomic`: returns a pipeline wrapped in a MULTI / EXEC transaction
|
||||
(class: `Predis\Pipeline\Atomic`).
|
||||
- `fire-and-forget`: returns a pipeline that does not read back responses
|
||||
(class: `Predis\Pipeline\FireAndForget`).
|
||||
|
||||
- Most classes and interfaces in the `Predis\Protocol` namespace have been moved
|
||||
or renamed while rationalizing the whole API of external protocol processors.
|
||||
|
||||
@@ -371,7 +371,15 @@ class Client implements ClientInterface
|
||||
*/
|
||||
protected function createPipeline(array $options = null, $callable = null)
|
||||
{
|
||||
$pipeline = new Pipeline\Pipeline($this);
|
||||
if (isset($options['atomic']) && $options['atomic']) {
|
||||
$class = 'Predis\Pipeline\Atomic';
|
||||
} else if (isset($options['fire-and-forget']) && $options['fire-and-forget']) {
|
||||
$class = 'Predis\Pipeline\FireAndForget';
|
||||
} else {
|
||||
$class = 'Predis\Pipeline\Pipeline';
|
||||
}
|
||||
|
||||
$pipeline = new $class($this);
|
||||
|
||||
if (isset($callable)) {
|
||||
return $pipeline->execute($callable);
|
||||
|
||||
@@ -581,9 +581,10 @@ class ClientTest extends StandardTestCase
|
||||
public function testPipelineWithArrayReturnsPipeline()
|
||||
{
|
||||
$client = new Client();
|
||||
$options = array();
|
||||
|
||||
$this->assertInstanceOf('Predis\Pipeline\Pipeline', $client->pipeline($options));
|
||||
$this->assertInstanceOf('Predis\Pipeline\Pipeline', $client->pipeline(array()));
|
||||
$this->assertInstanceOf('Predis\Pipeline\Atomic', $client->pipeline(array('atomic' => true)));
|
||||
$this->assertInstanceOf('Predis\Pipeline\FireAndForget', $client->pipeline(array('fire-and-forget' => true)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user