Commit dc4be23e authored by antirez's avatar antirez
Browse files

binary safe keys ready implementation of RANDOMKEYS

parent 24df7698
......@@ -4234,18 +4234,25 @@ static void selectCommand(redisClient *c) {
static void randomkeyCommand(redisClient *c) {
dictEntry *de;
robj *key;
while(1) {
de = dictGetRandomKey(c->db->dict);
if (!de || expireIfNeeded(c->db,dictGetEntryKey(de)) == 0) break;
}
if (de == NULL) {
addReply(c,shared.plus);
addReply(c,shared.crlf);
addReply(c,shared.nullbulk);
return;
}
key = dictGetEntryKey(de);
if (server.vm_enabled) {
key = dupStringObject(key);
addReplyBulk(c,key);
decrRefCount(key);
} else {
addReply(c,shared.plus);
addReply(c,dictGetEntryKey(de));
addReply(c,shared.crlf);
addReplyBulk(c,key);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment