mirror of
https://github.com/predis/predis.git
synced 2026-09-11 02:46:59 +00:00
New command: LINSERT (Redis v2.2-dev).
This commit is contained in:
@@ -1749,6 +1749,9 @@ class RedisServer_vNext extends RedisServer_v2_0 {
|
||||
|
||||
/* commands operating on string values */
|
||||
'strlen' => '\Predis\Commands\Strlen',
|
||||
|
||||
/* commands operating on lists */
|
||||
'linsert' => '\Predis\Commands\ListInsert',
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -2403,6 +2406,10 @@ class ListPopLastBlocking extends Command {
|
||||
public function getCommandId() { return 'BRPOP'; }
|
||||
}
|
||||
|
||||
class ListInsert extends Command {
|
||||
public function getCommandId() { return 'LINSERT'; }
|
||||
}
|
||||
|
||||
/* commands operating on sets */
|
||||
class SetAdd extends Command {
|
||||
public function getCommandId() { return 'SADD'; }
|
||||
|
||||
@@ -693,6 +693,22 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals((float)(time() - $start), 2, '', 1);
|
||||
}
|
||||
|
||||
function testListInsert() {
|
||||
$numbers = RC::pushTailAndReturn($this->redis, 'numbers', RC::getArrayOfNumbers());
|
||||
|
||||
$this->assertEquals(11, $this->redis->linsert('numbers', 'before', 0, -2));
|
||||
$this->assertEquals(12, $this->redis->linsert('numbers', 'after', -2, -1));
|
||||
$this->assertEquals(array(-2, -1, 0, 1), $this->redis->lrange('numbers', 0, 3));
|
||||
|
||||
$this->assertEquals(-1, $this->redis->linsert('numbers', 'after', 100, 200));
|
||||
$this->assertEquals(-1, $this->redis->linsert('numbers', 'before', 100, 50));
|
||||
|
||||
RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function($test) {
|
||||
$test->redis->set('foo', 'bar');
|
||||
$test->redis->lset('foo', 0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* commands operating on sets */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user