Search code examples
redisredis-clusterredis-cli

redis cluster dbsize shows keys only on that node


I'm connecting to a redis cluster node using

redis-cli -c -p 7001

When I issue info command or dbsize command, I get the count of keys that only reside on that node, and not the count of all the keys across all the nodes in my cluster. However, if I ask for a key which doesn't reside on this node, it gets me the key from that node. What if I want keys * to yield all keys from all the available nodes?


Solution

  • When talking to a Redis instance of any kind, you are only talking to that specific instance. Thus any commands are only executed in and for that instance's context. If you want to aggregate key counts across the cluster you have to issue the command on every master node and sum the results.