mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
KEYS now returns a multi bulk reply
This commit is contained in:
parent
18b6cb7643
commit
a3f9eec291
10
redis.c
10
redis.c
@ -3820,7 +3820,7 @@ static void keysCommand(redisClient *c) {
|
|||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
sds pattern = c->argv[1]->ptr;
|
sds pattern = c->argv[1]->ptr;
|
||||||
int plen = sdslen(pattern);
|
int plen = sdslen(pattern);
|
||||||
unsigned long numkeys = 0, keyslen = 0;
|
unsigned long numkeys = 0;
|
||||||
robj *lenobj = createObject(REDIS_STRING,NULL);
|
robj *lenobj = createObject(REDIS_STRING,NULL);
|
||||||
|
|
||||||
di = dictGetIterator(c->db->dict);
|
di = dictGetIterator(c->db->dict);
|
||||||
@ -3833,17 +3833,15 @@ static void keysCommand(redisClient *c) {
|
|||||||
if ((pattern[0] == '*' && pattern[1] == '\0') ||
|
if ((pattern[0] == '*' && pattern[1] == '\0') ||
|
||||||
stringmatchlen(pattern,plen,key,sdslen(key),0)) {
|
stringmatchlen(pattern,plen,key,sdslen(key),0)) {
|
||||||
if (expireIfNeeded(c->db,keyobj) == 0) {
|
if (expireIfNeeded(c->db,keyobj) == 0) {
|
||||||
if (numkeys != 0)
|
addReplyBulkLen(c,keyobj);
|
||||||
addReply(c,shared.space);
|
|
||||||
addReply(c,keyobj);
|
addReply(c,keyobj);
|
||||||
|
addReply(c,shared.crlf);
|
||||||
numkeys++;
|
numkeys++;
|
||||||
keyslen += sdslen(key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dictReleaseIterator(di);
|
dictReleaseIterator(di);
|
||||||
lenobj->ptr = sdscatprintf(sdsempty(),"$%lu\r\n",keyslen+(numkeys ? (numkeys-1) : 0));
|
lenobj->ptr = sdscatprintf(sdsempty(),"*%lu\r\n",numkeys);
|
||||||
addReply(c,shared.crlf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dbsizeCommand(redisClient *c) {
|
static void dbsizeCommand(redisClient *c) {
|
||||||
|
@ -178,7 +178,7 @@ proc createComplexDataset {r ops} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc datasetDigest r {
|
proc datasetDigest r {
|
||||||
set keys [lsort [split [$r keys *] " "]]
|
set keys [lsort [$r keys *]]
|
||||||
set digest {}
|
set digest {}
|
||||||
foreach k $keys {
|
foreach k $keys {
|
||||||
set t [$r type $k]
|
set t [$r type $k]
|
||||||
@ -204,7 +204,7 @@ proc datasetDigest r {
|
|||||||
set aux [::sha1::sha1 -hex [$r zrange $k 0 -1]]
|
set aux [::sha1::sha1 -hex [$r zrange $k 0 -1]]
|
||||||
}
|
}
|
||||||
} default {
|
} default {
|
||||||
error "Type not supported"
|
error "Type not supported: $t"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {$aux eq {}} continue
|
if {$aux eq {}} continue
|
||||||
|
Loading…
Reference in New Issue
Block a user