Forráskód Böngészése

Change the default value for the number of arguments used to populate KEYS.

Daniele Alessandri 14 éve
szülő
commit
0e0cd865e7
1 módosított fájl, 5 hozzáadás és 13 törlés
  1. 5 13
      lib/Predis/Commands/ScriptedCommand.php

+ 5 - 13
lib/Predis/Commands/ScriptedCommand.php

@@ -6,24 +6,16 @@ abstract class ScriptedCommand extends ServerEval {
     public abstract function getScript();
 
     protected function keysCount() {
-        // The default behaviour is to use the first argument as the only value
-        // for KEYS and the rest of the arguments (if any) for ARGV. When -1 is
-        // returned, all the arguments are considered as values for KEYS.
-        return 1;
+        // The default behaviour for the base class is to use all the arguments
+        // passed to a scripted command to populate the KEYS table in Lua.
+        return count($this->getArguments());
     }
 
     protected function filterArguments(Array $arguments) {
-        if (($keys = $this->keysCount()) === -1) {
-            $keys = count($arguments);
-        }
-        return array_merge(array($this->getScript(), $keys), $arguments);
+        return array_merge(array($this->getScript(), $this->keysCount()), $arguments);
     }
 
     protected function getKeys() {
-        $arguments = $this->getArguments();
-        if (($keys = $this->keysCount()) === -1) {
-            return array_slice($arguments, 2);
-        }
-        return array_slice($arguments, 2, $keys);
+        return array_slice($this->getArguments(), 2, $this->keysCount());
     }
 }