Move classes related to MULTI/EXEC abstraction to the Predis\Transaction namespace.

This commit is contained in:
Daniele Alessandri
2011-06-02 17:20:18 +02:00
parent fee3866f54
commit 6ad73c782a
6 changed files with 28 additions and 16 deletions
-7
View File
@@ -1,7 +0,0 @@
<?php
namespace Predis;
class AbortedMultiExec extends PredisException {
// Aborted MULTI/EXEC transactions
}
+1
View File
@@ -8,6 +8,7 @@ use Predis\Network\IConnectionSingle;
use Predis\Profiles\IServerProfile;
use Predis\Profiles\ServerProfile;
use Predis\Pipeline\PipelineContext;
use Predis\Transaction\MultiExecContext;
class Client {
const VERSION = '0.7.0-dev';
@@ -0,0 +1,9 @@
<?php
namespace Predis\Transaction;
use Predis\PredisException;
class AbortedMultiExecException extends PredisException {
// Aborted MULTI/EXEC transactions
}
@@ -1,6 +1,14 @@
<?php
namespace Predis;
namespace Predis\Transaction;
use Predis\Client;
use Predis\Helpers;
use Predis\ResponseQueued;
use Predis\ClientException;
use Predis\ServerException;
use Predis\ProtocolException;
use Predis\CommunicationException;
class MultiExecContext {
private $_initialized, $_discarded, $_insideBlock, $_checkAndSet, $_watchedKeys;
@@ -186,7 +194,7 @@ class MultiExecContext {
$reply = $this->_client->exec();
if ($reply === null) {
if ($attemptsLeft === 0) {
throw new AbortedMultiExec(
throw new AbortedMultiExecException(
'The current transaction has been aborted by the server'
);
}
+6 -5
View File
@@ -486,14 +486,15 @@ class ClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
$client->flushdb();
$multi = $client->multiExec();
$transactionClass = '\Predis\Transaction\MultiExecContext';
$this->assertInstanceOf('\Predis\MultiExecContext', $multi);
$this->assertInstanceOf('\Predis\MultiExecContext', $multi->set('foo', 'bar'));
$this->assertInstanceOf('\Predis\MultiExecContext', $multi->set('hoge', 'piyo'));
$this->assertInstanceOf('\Predis\MultiExecContext', $multi->mset(array(
$this->assertInstanceOf($transactionClass, $multi);
$this->assertInstanceOf($transactionClass, $multi->set('foo', 'bar'));
$this->assertInstanceOf($transactionClass, $multi->set('hoge', 'piyo'));
$this->assertInstanceOf($transactionClass, $multi->mset(array(
'foofoo' => 'barbar', 'hogehoge' => 'piyopiyo'
)));
$this->assertInstanceOf('\Predis\MultiExecContext', $multi->mget(array(
$this->assertInstanceOf($transactionClass, $multi->mget(array(
'foo', 'hoge', 'foofoo', 'hogehoge'
)));
+2 -2
View File
@@ -168,10 +168,10 @@ class RC {
try {
$wrapFunction($testcaseInstance);
}
catch (Predis\AbortedMultiExec $exception) {
catch (Predis\Transaction\AbortedMultiExecException $exception) {
$thrownException = $exception;
}
$testcaseInstance->assertInstanceOf('Predis\AbortedMultiExec', $thrownException);
$testcaseInstance->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $thrownException);
}
public static function pushTailAndReturn(Predis\Client $client, $keyName, Array $values, $wipeOut = 0) {