Explorar o código

Implement variadic SADD in the development profile (Redis v2.4).

Daniele Alessandri %!s(int64=14) %!d(string=hai) anos
pai
achega
a8705b9535

+ 20 - 0
lib/Predis/Commands/SetAddV24x.php

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

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

@@ -10,6 +10,9 @@ class ServerVersionNext extends ServerVersion22 {
             'rpush'                 => '\Predis\Commands\ListPushTailV24x',
             'lpush'                 => '\Predis\Commands\ListPushHeadV24x',
 
+            /* commands operating on sets */
+            'sadd'                      => '\Predis\Commands\SetAddV24x',
+
             /* remote server control commands */
             'info'                  => '\Predis\Commands\InfoV24x',
         ));