Browse Source

Implement variadic RPUSH and LPUSH in the development profile (Redis v2.4).

Daniele Alessandri 14 years ago
parent
commit
66f6610c72

+ 9 - 0
lib/Predis/Commands/ListPushHeadV24x.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace Predis\Commands;
+
+class ListPushHeadV24x extends ListPushTailV24x {
+    public function getId() {
+        return 'LPUSH';
+    }
+}

+ 16 - 0
lib/Predis/Commands/ListPushTailV24x.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace Predis\Commands;
+
+class ListPushTailV24x extends Command {
+    public function getId() {
+        return 'RPUSH';
+    }
+
+    public function filterArguments(Array $arguments) {
+        if (count($arguments) === 2 && is_array($arguments[1])) {
+            return array_merge(array($arguments[0]), $arguments[1]);
+        }
+        return $arguments;
+    }
+}

+ 4 - 0
lib/Predis/Profiles/ServerVersionNext.php

@@ -6,6 +6,10 @@ class ServerVersionNext extends ServerVersion22 {
     public function getVersion() { return '2.4'; }
     public function getSupportedCommands() {
         return array_merge(parent::getSupportedCommands(), array(
+            /* commands operating on lists */
+            'rpush'                 => '\Predis\Commands\ListPushTailV24x',
+            'lpush'                 => '\Predis\Commands\ListPushHeadV24x',
+
             /* remote server control commands */
             'info'                  => '\Predis\Commands\InfoV24x',
         ));