瀏覽代碼

New commands: PSETEX, PEXPIRE, PEXPIREAT, PTTL (Redis v2.6-dev).

Daniele Alessandri 13 年之前
父節點
當前提交
51b998720e

+ 2 - 1
TODO

@@ -13,4 +13,5 @@
 
 * Missing tests for commands:
     PUBLISH, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, DEBUG, OBJECT,
-    CLIENT, CONFIG GET, CONFIG SET, CONFIG RESETSTAT, SLOWLOG, SCRIPT
+    CLIENT, CONFIG GET, CONFIG SET, CONFIG RESETSTAT, SLOWLOG, SCRIPT, PTTL,
+    PSETEX, PEXPIRE, PEXPIREAT

+ 27 - 0
lib/Predis/Commands/KeyPreciseExpire.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Commands;
+
+/**
+ * @link http://redis.io/commands/pexpire
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class KeyPreciseExpire extends KeyExpire
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getId()
+    {
+        return 'PEXPIRE';
+    }
+}

+ 27 - 0
lib/Predis/Commands/KeyPreciseExpireAt.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Commands;
+
+/**
+ * @link http://redis.io/commands/pexpireat
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class KeyPreciseExpireAt extends KeyExpireAt
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getId()
+    {
+        return 'PEXPIREAT';
+    }
+}

+ 27 - 0
lib/Predis/Commands/KeyPreciseTimeToLive.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Commands;
+
+/**
+ * @link http://redis.io/commands/pttl
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class KeyPreciseTimeToLive extends KeyTimeToLive
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getId()
+    {
+        return 'PTTL';
+    }
+}

+ 27 - 0
lib/Predis/Commands/StringPreciseSetExpire.php

@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Commands;
+
+/**
+ * @link http://redis.io/commands/psetex
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class StringPreciseSetExpire extends StringSetExpire
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getId()
+    {
+        return 'PSETEX';
+    }
+}

+ 12 - 1
lib/Predis/Profiles/ServerVersionNext.php

@@ -32,10 +32,21 @@ class ServerVersionNext extends ServerVersion24
     public function getSupportedCommands()
     {
         return array_merge(parent::getSupportedCommands(), array(
-            'info'                      => '\Predis\Commands\ServerInfoV26x',
+            /* commands operating on the key space */
+            'pttl'                      => '\Predis\Commands\KeyPreciseTimeToLive',
+            'pexpire'                   => '\Predis\Commands\KeyPreciseExpire',
+            'pexpireat'                 => '\Predis\Commands\KeyPreciseExpireAt',
+
+            /* commands operating on string values */
+            'psetex'                    => '\Predis\Commands\StringPreciseSetExpire',
+
+            /* scripting */
             'eval'                      => '\Predis\Commands\ServerEval',
             'evalsha'                   => '\Predis\Commands\ServerEvalSHA',
             'script'                    => '\Predis\Commands\ServerScript',
+
+            /* remote server control commands */
+            'info'                      => '\Predis\Commands\ServerInfoV26x',
         ));
     }
 }