Cluster: new sub-command CLUSTER COUNTKEYSINSLOT.

The new sub-command uses the new countKeysInSlot() API and allows a
cluster client to get the number of keys for a given hashslot.
This commit is contained in:
antirez 2013-02-25 12:04:31 +01:00
parent a517c89321
commit d4fa40655d

View File

@ -1640,6 +1640,12 @@ void clusterCommand(redisClient *c) {
sds key = c->argv[2]->ptr;
addReplyLongLong(c,keyHashSlot(key,sdslen(key)));
} else if (!strcasecmp(c->argv[1]->ptr,"countkeysinslot") && c->argc == 3) {
long long slot;
if (getLongLongFromObjectOrReply(c,c->argv[2],&slot,NULL) != REDIS_OK)
return;
addReplyLongLong(c,countKeysInSlot(slot));
} else if (!strcasecmp(c->argv[1]->ptr,"getkeysinslot") && c->argc == 4) {
long long maxkeys, slot;
unsigned int numkeys, j;