mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
binary safe keys ready implementation of RANDOMKEYS
This commit is contained in:
parent
24df76987e
commit
dc4be23ec8
17
redis.c
17
redis.c
@ -4234,18 +4234,25 @@ static void selectCommand(redisClient *c) {
|
|||||||
|
|
||||||
static void randomkeyCommand(redisClient *c) {
|
static void randomkeyCommand(redisClient *c) {
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
|
robj *key;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
de = dictGetRandomKey(c->db->dict);
|
de = dictGetRandomKey(c->db->dict);
|
||||||
if (!de || expireIfNeeded(c->db,dictGetEntryKey(de)) == 0) break;
|
if (!de || expireIfNeeded(c->db,dictGetEntryKey(de)) == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (de == NULL) {
|
if (de == NULL) {
|
||||||
addReply(c,shared.plus);
|
addReply(c,shared.nullbulk);
|
||||||
addReply(c,shared.crlf);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
key = dictGetEntryKey(de);
|
||||||
|
if (server.vm_enabled) {
|
||||||
|
key = dupStringObject(key);
|
||||||
|
addReplyBulk(c,key);
|
||||||
|
decrRefCount(key);
|
||||||
} else {
|
} else {
|
||||||
addReply(c,shared.plus);
|
addReplyBulk(c,key);
|
||||||
addReply(c,dictGetEntryKey(de));
|
|
||||||
addReply(c,shared.crlf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user