mirror of
https://github.com/predis/predis.git
synced 2026-09-19 06:47:39 +00:00
Minor fixes and adjustments to pipeline executors.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\ServerException;
|
||||
use Predis\CommunicationException;
|
||||
use Predis\Network\IConnection;
|
||||
|
||||
class SafeClusterExecutor implements IPipelineExecutor {
|
||||
@@ -18,7 +20,7 @@ class SafeClusterExecutor implements IPipelineExecutor {
|
||||
try {
|
||||
$cmdConnection->writeCommand($command);
|
||||
}
|
||||
catch (\Predis\CommunicationException $exception) {
|
||||
catch (CommunicationException $exception) {
|
||||
$connectionExceptions[spl_object_hash($cmdConnection)] = $exception;
|
||||
}
|
||||
}
|
||||
@@ -42,10 +44,10 @@ class SafeClusterExecutor implements IPipelineExecutor {
|
||||
: $response
|
||||
);
|
||||
}
|
||||
catch (\Predis\ServerException $exception) {
|
||||
catch (ServerException $exception) {
|
||||
$values[] = $exception->toResponseError();
|
||||
}
|
||||
catch (\Predis\CommunicationException $exception) {
|
||||
catch (CommunicationException $exception) {
|
||||
$values[] = $exception;
|
||||
$connectionExceptions[$connectionObjectHash] = $exception;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\ServerException;
|
||||
use Predis\CommunicationException;
|
||||
use Predis\Network\IConnection;
|
||||
|
||||
class SafeExecutor implements IPipelineExecutor {
|
||||
@@ -13,7 +15,7 @@ class SafeExecutor implements IPipelineExecutor {
|
||||
try {
|
||||
$connection->writeCommand($command);
|
||||
}
|
||||
catch (\Predis\CommunicationException $exception) {
|
||||
catch (CommunicationException $exception) {
|
||||
return array_fill(0, $sizeofPipe, $exception);
|
||||
}
|
||||
}
|
||||
@@ -28,10 +30,10 @@ class SafeExecutor implements IPipelineExecutor {
|
||||
: $response
|
||||
);
|
||||
}
|
||||
catch (\Predis\ServerException $exception) {
|
||||
catch (ServerException $exception) {
|
||||
$values[] = $exception->toResponseError();
|
||||
}
|
||||
catch (\Predis\CommunicationException $exception) {
|
||||
catch (CommunicationException $exception) {
|
||||
$toAdd = count($commands) - count($values);
|
||||
$values = array_merge($values, array_fill(0, $toAdd, $exception));
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Predis\Pipeline;
|
||||
|
||||
use Predis\ServerException;
|
||||
use Predis\Network\IConnection;
|
||||
|
||||
class StandardExecutor implements IPipelineExecutor {
|
||||
@@ -15,13 +16,13 @@ class StandardExecutor implements IPipelineExecutor {
|
||||
try {
|
||||
for ($i = 0; $i < $sizeofPipe; $i++) {
|
||||
$response = $connection->readResponse($commands[$i]);
|
||||
$values[] = $response instanceof Iterator
|
||||
$values[] = $response instanceof \Iterator
|
||||
? iterator_to_array($response)
|
||||
: $response;
|
||||
unset($commands[$i]);
|
||||
}
|
||||
}
|
||||
catch (\Predis\ServerException $exception) {
|
||||
catch (ServerException $exception) {
|
||||
// Force disconnection to prevent protocol desynchronization.
|
||||
$connection->disconnect();
|
||||
throw $exception;
|
||||
|
||||
Reference in New Issue
Block a user