Commit 1abce146 authored by antirez's avatar antirez
Browse files

Cluster: added new API countKeysInSlot().

This is similar to getKeysInSlot() but just returns the number of keys
found in a given hash slot, without returning the keys.
parent 825e07f2
......@@ -778,3 +778,19 @@ unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int coun
}
return j;
}
unsigned int CountKeysInSlot(unsigned int hashslot) {
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) {
j++;
n = n->level[0].forward;
}
return j;
}
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