Parcourir la source

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

Daniele Alessandri il y a 14 ans
Parent
commit
b530f9f613
2 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 8 0
      lib/Predis.php
  2. 12 0
      test/RedisCommandsTest.php

+ 8 - 0
lib/Predis.php

@@ -1822,6 +1822,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',
@@ -2400,6 +2403,11 @@ class ExpireAt extends \Predis\MultiBulkCommand {
     public function parseResponse($data) { return (bool) $data; }
 }
 
+class Persist extends \Predis\MultiBulkCommand {
+    public function getCommandId() { return 'PERSIST'; }
+    public function parseResponse($data) { return (bool) $data; }
+}
+
 class DatabaseSize extends \Predis\MultiBulkCommand {
     public function canBeHashed()  { return false; }
     public function getCommandId() { return 'DBSIZE'; }

+ 12 - 0
test/RedisCommandsTest.php

@@ -337,6 +337,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'));