From 51352bcbb3303a49a034a47e76f04b82f651adbf Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 4 Jan 2011 21:01:29 +0100 Subject: [PATCH] Create a new class to handle the old response type of KEYS (Redis v1.2). --- lib/Predis.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Predis.php b/lib/Predis.php index 8ef0dc61..64c03f4a 100644 --- a/lib/Predis.php +++ b/lib/Predis.php @@ -1706,7 +1706,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', 'rename' => '\Predis\Commands\Rename', 'renamenx' => '\Predis\Commands\RenamePreserve', @@ -1792,6 +1792,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', 'brpop' => '\Predis\Commands\ListPopLastBlocking', @@ -2425,12 +2428,11 @@ class Strlen extends Command { class Keys extends Command { 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); } }