From a3f9eec291993853095941348e80818d91e07c5f Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 1 Mar 2010 23:46:24 +0100 Subject: [PATCH] KEYS now returns a multi bulk reply --- redis.c | 10 ++++------ test-redis.tcl | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/redis.c b/redis.c index 319a0afff..c10fb03af 100644 --- a/redis.c +++ b/redis.c @@ -3820,7 +3820,7 @@ static void keysCommand(redisClient *c) { dictEntry *de; sds pattern = c->argv[1]->ptr; int plen = sdslen(pattern); - unsigned long numkeys = 0, keyslen = 0; + unsigned long numkeys = 0; robj *lenobj = createObject(REDIS_STRING,NULL); di = dictGetIterator(c->db->dict); @@ -3833,17 +3833,15 @@ static void keysCommand(redisClient *c) { if ((pattern[0] == '*' && pattern[1] == '\0') || stringmatchlen(pattern,plen,key,sdslen(key),0)) { if (expireIfNeeded(c->db,keyobj) == 0) { - if (numkeys != 0) - addReply(c,shared.space); + addReplyBulkLen(c,keyobj); addReply(c,keyobj); + addReply(c,shared.crlf); numkeys++; - keyslen += sdslen(key); } } } dictReleaseIterator(di); - lenobj->ptr = sdscatprintf(sdsempty(),"$%lu\r\n",keyslen+(numkeys ? (numkeys-1) : 0)); - addReply(c,shared.crlf); + lenobj->ptr = sdscatprintf(sdsempty(),"*%lu\r\n",numkeys); } static void dbsizeCommand(redisClient *c) { diff --git a/test-redis.tcl b/test-redis.tcl index 83dfd0b4a..6eea1189f 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -178,7 +178,7 @@ proc createComplexDataset {r ops} { } proc datasetDigest r { - set keys [lsort [split [$r keys *] " "]] + set keys [lsort [$r keys *]] set digest {} foreach k $keys { set t [$r type $k] @@ -204,7 +204,7 @@ proc datasetDigest r { set aux [::sha1::sha1 -hex [$r zrange $k 0 -1]] } } default { - error "Type not supported" + error "Type not supported: $t" } } if {$aux eq {}} continue