mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 01:20:50 +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:
parent
825e07f2fd
commit
1abce14611
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;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user