From 21b3fdb3e13ab42338d52abbefa5c4ed15446cf2 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sun, 28 Nov 2010 16:35:25 +0100 Subject: [PATCH] New command: PERSIST (Redis v2.2-dev). --- lib/Predis.php | 8 ++++++++ test/RedisCommandsTest.php | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/Predis.php b/lib/Predis.php index 90636a4a..43f7014c 100644 --- a/lib/Predis.php +++ b/lib/Predis.php @@ -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'; } diff --git a/test/RedisCommandsTest.php b/test/RedisCommandsTest.php index cc4d93bd..3b968e11 100644 --- a/test/RedisCommandsTest.php +++ b/test/RedisCommandsTest.php @@ -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'));