New command: LINSERT (Redis v2.2-dev).

This commit is contained in:
Daniele Alessandri
2010-09-21 17:21:06 +02:00
parent 73b4760fc4
commit 49a140e3af
2 changed files with 23 additions and 0 deletions
+7
View File
@@ -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'; }
+16
View File
@@ -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 */