mirror of
https://github.com/predis/predis.git
synced 2026-08-31 12:43:31 +00:00
Merge branch 'cmd_lpoppush'
This commit is contained in:
@@ -223,6 +223,8 @@ class Client {
|
||||
'popFirst' => '\Predis\Commands\ListPopFirst',
|
||||
'rpop' => '\Predis\Commands\ListPopLast',
|
||||
'popLast' => '\Predis\Commands\ListPopLast',
|
||||
'rpoplpush' => '\Predis\Commands\ListPushTailPopFirst',
|
||||
'listPushTailPopFist' => '\Predis\Commands\ListPushTailPopFirst',
|
||||
|
||||
/* commands operating on sets */
|
||||
'sadd' => '\Predis\Commands\SetAdd',
|
||||
@@ -900,6 +902,10 @@ class ListRemove extends \Predis\BulkCommand {
|
||||
public function getCommandId() { return 'LREM'; }
|
||||
}
|
||||
|
||||
class ListPushTailPopFirst extends \Predis\BulkCommand {
|
||||
public function getCommandId() { return 'RPOPLPUSH'; }
|
||||
}
|
||||
|
||||
class ListPopFirst extends \Predis\InlineCommand {
|
||||
public function getCommandId() { return 'LPOP'; }
|
||||
}
|
||||
|
||||
@@ -505,6 +505,37 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
|
||||
function testListPushTailPopFist() {
|
||||
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', array(0, 1, 2));
|
||||
$this->assertEquals(0, $this->redis->listLength('temporary'));
|
||||
$this->assertEquals(2, $this->redis->listPushTailPopFist('numbers', 'temporary'));
|
||||
$this->assertEquals(1, $this->redis->listPushTailPopFist('numbers', 'temporary'));
|
||||
$this->assertEquals(0, $this->redis->listPushTailPopFist('numbers', 'temporary'));
|
||||
$this->assertEquals(0, $this->redis->listLength('numbers'));
|
||||
$this->assertEquals(3, $this->redis->listLength('temporary'));
|
||||
$this->assertEquals(array(), $this->redis->listRange('numbers', 0, -1));
|
||||
$this->assertEquals($numbers, $this->redis->listRange('temporary', 0, -1));
|
||||
|
||||
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', array(0, 1, 2));
|
||||
$this->redis->listPushTailPopFist('numbers', 'numbers');
|
||||
$this->redis->listPushTailPopFist('numbers', 'numbers');
|
||||
$this->redis->listPushTailPopFist('numbers', 'numbers');
|
||||
$this->assertEquals($numbers, $this->redis->listRange('numbers', 0, -1));
|
||||
|
||||
$this->assertEquals(null, $this->redis->listPushTailPopFist('listDoesNotExist1', 'listDoesNotExist2'));
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->listPushTailPopFist('foo', 'hoge');
|
||||
});
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->listPushTailPopFist('temporary', 'foo');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* commands operating on sets */
|
||||
|
||||
function testSetAdd() {
|
||||
|
||||
Reference in New Issue
Block a user