diff options
author | antirez <antirez@gmail.com> | 2013-02-25 11:15:03 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-02-25 11:15:03 +0100 |
commit | 1abce14611e01b38e0b461a12a01ce71b35a6342 (patch) | |
tree | cdf76557ccdd212bfea1b3f28b9826b03b9951e1 /src/db.c | |
parent | 825e07f2fd8949cffabcc0d5800ea46778dddafd (diff) | |
download | redis-1abce14611e01b38e0b461a12a01ce71b35a6342.tar.gz |
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.
Diffstat (limited to 'src/db.c')
-rw-r--r-- | src/db.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; +} |