mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 16:51:22 +00:00
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.
This commit is contained in:
16
src/db.c
16
src/db.c
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user