Minor fixes and adjustments to pipeline executors.

This commit is contained in:
Daniele Alessandri
2011-04-04 11:42:52 +02:00
parent c2a61a3113
commit 595692d50f
3 changed files with 13 additions and 8 deletions
+5 -3
View File
@@ -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;
}
+5 -3
View File
@@ -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;
+3 -2
View File
@@ -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;