CLUSTER GETKEYSINSLOT implemented

This commit is contained in:
antirez
2011-04-29 16:17:58 +02:00
parent 1eb713a4c1
commit 484354ff95
3 changed files with 29 additions and 3 deletions

View File

@ -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;
}