mirror of
https://github.com/predis/predis.git
synced 2026-09-13 03:47:03 +00:00
Remove the "safe" pipeline option.
Just let users specify the appropriate pipeline executor.
This commit is contained in:
@@ -68,16 +68,17 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac
|
||||
return $executor;
|
||||
}
|
||||
|
||||
if (isset($options['safe']) && $options['safe'] == true) {
|
||||
$isCluster = Helpers::isCluster($client->getConnection());
|
||||
return $isCluster ? new SafeClusterExecutor() : new SafeExecutor();
|
||||
}
|
||||
$clientOpts = $client->getOptions();
|
||||
$useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true;
|
||||
|
||||
return new StandardExecutor($useExceptions);
|
||||
}
|
||||
|
||||
protected function getDefaultExecutor()
|
||||
{
|
||||
$clientOpts = $client->getOptions();
|
||||
$useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true;
|
||||
$executor = new StandardExecutor($useExceptions);
|
||||
|
||||
return $executor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,16 +41,13 @@ class PipelineContextTest extends StandardTestCase
|
||||
{
|
||||
$client = new Client();
|
||||
$executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface');
|
||||
|
||||
$pipeline = new PipelineContext($client, array('executor' => $executor));
|
||||
$this->assertSame($executor, $pipeline->getExecutor());
|
||||
|
||||
$pipeline = new PipelineContext($client, array('safe' => true));
|
||||
$this->assertInstanceOf('Predis\Pipeline\SafeExecutor', $pipeline->getExecutor());
|
||||
|
||||
$options = array('executor' => 'safe');
|
||||
$client = new Client($this->getMock('Predis\Connection\ClusterConnectionInterface'));
|
||||
$pipeline = new PipelineContext($client, array('safe' => true));
|
||||
$this->assertInstanceOf('Predis\Pipeline\SafeClusterExecutor', $pipeline->getExecutor());
|
||||
$executorCbk = function($client, $options) use($executor) { return $executor; };
|
||||
$pipeline = new PipelineContext($client, array('executor' => $executorCbk));
|
||||
$this->assertSame($executor, $pipeline->getExecutor());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user