Browse Source

Create a new class to handle the old response type of KEYS (Redis v1.2).

Daniele Alessandri 14 years ago
parent
commit
455e56927a
1 changed files with 9 additions and 7 deletions
  1. 9 7
      lib/Predis.php

+ 9 - 7
lib/Predis.php

@@ -1662,7 +1662,7 @@ class RedisServer_v1_2 extends RedisServerProfile {
             'type'                    => '\Predis\Commands\Type',
 
             /* commands operating on the key space */
-            'keys'               => '\Predis\Commands\Keys',
+            'keys'               => '\Predis\Commands\Keys_v1_2',
             'randomkey'          => '\Predis\Commands\RandomKey',
                 'randomKey'      => '\Predis\Commands\RandomKey',
             'rename'             => '\Predis\Commands\Rename',
@@ -1796,6 +1796,9 @@ class RedisServer_v2_0 extends RedisServer_v1_2 {
             'append'                    => '\Predis\Commands\Append',
             'substr'                    => '\Predis\Commands\Substr',
 
+            /* commands operating on the key space */
+            'keys'                      => '\Predis\Commands\Keys',
+
             /* commands operating on lists */
             'blpop'                     => '\Predis\Commands\ListPopFirstBlocking',
                 'popFirstBlocking'      => '\Predis\Commands\ListPopFirstBlocking',
@@ -2429,12 +2432,11 @@ class Strlen extends \Predis\MultiBulkCommand {
 class Keys extends \Predis\MultiBulkCommand {
     public function canBeHashed()  { return false; }
     public function getCommandId() { return 'KEYS'; }
-    public function parseResponse($data) { 
-        // TODO: is this behaviour correct?
-        if (is_array($data) || $data instanceof \Iterator) {
-            return $data;
-        }
-        return strlen($data) > 0 ? explode(' ', $data) : array();
+}
+
+class Keys_v1_2 extends Keys {
+    public function parseResponse($data) {
+        return explode(' ', $data);
     }
 }