-
-/* Slot to Key API. This is used by Redis Cluster in order to obtain in
- * a fast way a key that belongs to a specified hash slot. This is useful
- * while rehashing the cluster. */
-void SlotToKeyAdd(robj *key) {
- unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
-
- zslInsert(server.cluster.slots_to_keys,hashslot,key);
- incrRefCount(key);
-}
-
-void SlotToKeyDel(robj *key) {
- unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));
-
- zslDelete(server.cluster.slots_to_keys,hashslot,key);
-}
-
-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);
- while(n && n->score == hashslot && count--) {
- keys[j++] = n->obj;
- n = n->level[0].forward;
- }
- return j;
-}