mirror of
https://github.com/predis/predis.git
synced 2026-08-30 12:15:03 +00:00
Support DISCARD with CAS.
This commit is contained in:
+4
-1
@@ -850,8 +850,11 @@ class MultiExecBlock {
|
||||
if (isset($options['watch'])) {
|
||||
$this->watch($options['watch']);
|
||||
}
|
||||
if (!$this->_checkAndSet) {
|
||||
if (!$this->_checkAndSet || ($this->_discarded && $this->_checkAndSet)) {
|
||||
$this->_redisClient->multi();
|
||||
if ($this->_discarded) {
|
||||
$this->_checkAndSet = false;
|
||||
}
|
||||
}
|
||||
$this->_initialized = true;
|
||||
$this->_discarded = false;
|
||||
|
||||
@@ -636,5 +636,23 @@ class PredisClientFeaturesTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$this->assertType('array', $replies);
|
||||
$this->assertEquals(array(true, array('bar', 'bar')), $replies);
|
||||
}
|
||||
|
||||
function testMultiExecBlock_CheckAndSet_Discard() {
|
||||
$client = RC::getConnection();
|
||||
$client->flushdb();
|
||||
$client->set('foo', 'bar');
|
||||
|
||||
$options = array('watch' => 'foo', 'cas' => true);
|
||||
$replies = $client->multiExec($options, function($tx) {
|
||||
$tx->watch('foobar');
|
||||
$foo = $tx->get('foo');
|
||||
$tx->multi();
|
||||
$tx->set('foobar', $foo);
|
||||
$tx->discard();
|
||||
$tx->mget('foo', 'foobar');
|
||||
});
|
||||
$this->assertType('array', $replies);
|
||||
$this->assertEquals(array(array('bar', null)), $replies);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user