From d4fa40655dfdbc9bbff9299f773812452875c6c8 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 25 Feb 2013 12:04:31 +0100 Subject: [PATCH] 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. --- src/cluster.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cluster.c b/src/cluster.c index e52af78b2..ce0bb8aa2 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -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;