Skip to content

Commit

Permalink
KEYS now returns a multi bulk reply
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Mar 1, 2010
1 parent 18b6cb7 commit a3f9eec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test-redis.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit a3f9eec

Please sign in to comment.