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

This commit is contained in:
Daniele Alessandri
2010-11-28 16:35:25 +01:00
parent cd9dbb763e
commit 21b3fdb3e1
2 changed files with 20 additions and 0 deletions
+8
View File
@@ -1794,6 +1794,9 @@ class RedisServer_vNext extends RedisServer_v2_0 {
/* commands operating on string values */
'strlen' => '\Predis\Commands\Strlen',
/* commands operating on the key space */
'persist' => '\Predis\Commands\Persist',
/* commands operating on lists */
'rpushx' => '\Predis\Commands\ListPushTailX',
'lpushx' => '\Predis\Commands\ListPushHeadX',
@@ -2389,6 +2392,11 @@ class ExpireAt extends Command {
public function parseResponse($data) { return (bool) $data; }
}
class Persist extends Command {
public function getCommandId() { return 'PERSIST'; }
public function parseResponse($data) { return (bool) $data; }
}
class DatabaseSize extends Command {
public function canBeHashed() { return false; }
public function getCommandId() { return 'DBSIZE'; }
+12
View File
@@ -334,6 +334,18 @@ class RedisCommandTestSuite extends PHPUnit_Framework_TestCase {
$this->assertEquals(-1, $this->redis->ttl('foo'));
}
function testPersist() {
$this->redis->set('foo', 'bar');
$this->assertTrue($this->redis->expire('foo', 1));
$this->assertEquals(1, $this->redis->ttl('foo'));
$this->assertTrue($this->redis->persist('foo'));
$this->assertEquals(-1, $this->redis->ttl('foo'));
$this->assertFalse($this->redis->persist('foo'));
$this->assertFalse($this->redis->persist('foobar'));
}
function testSetExpire() {
$this->assertTrue($this->redis->setex('foo', 10, 'bar'));
$this->assertTrue($this->redis->exists('foo'));