X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/c772d9c6e7a4b65075c6efd15a53e84bb3c7ba3f..da386cdf337a79b6734b58d3c5e426741e49c043:/src/db.c diff --git a/src/db.c b/src/db.c index 7d323924..354f9045 100644 --- a/src/db.c +++ b/src/db.c @@ -317,7 +317,7 @@ void existsCommand(redisClient *c) { void selectCommand(redisClient *c) { int id = atoi(c->argv[1]->ptr); - if (server.cluster_enabled) { + if (server.cluster_enabled && id != 0) { addReplyError(c,"SELECT is not allowed in cluster mode"); return; } @@ -725,14 +725,18 @@ void SlotToKeyDel(robj *key) { zslDelete(server.cluster.slots_to_keys,hashslot,key); } -robj *GetKeyInSlot(unsigned int hashslot) { +unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) { zskiplistNode *n; zrangespec range; + int j = 0; range.min = range.max = hashslot; range.minex = range.maxex = 0; n = zslFirstInRange(server.cluster.slots_to_keys, range); - if (!n) return NULL; - return n->obj; + while(n && n->score == hashslot && count--) { + keys[j++] = n->obj; + n = n->level[0].forward; + } + return j; }