You probably have cluster mode enabled. In cluster mode, the data you store is partitioned by key. One of the advantages of this is that you can now have a larger dataset than would reasonably fit on one machine (hundreds of terabytes, if you want) since every shard has some fraction of the entire data set.
A downside is that multi-key commands no long work like you would expect if the keys end up in different hash slots. The KEYS
command is such a multi-key command.
To make a long story short:
KEYS
is apparently giving you only the keys on the cluster node you're hitting. It would perhaps have been nicer to give you an error, instead, but it doesn't.
GET
is unaffected: redis-cli, with the -c
flag, knows how to find the right cluster node (perhaps after hitting the wrong one and being told the key has MOVED
).
If you ask every individual primary node in your cluster for KEYS *
, and add up all the results, you should get all the keys. This question has some examples of using the redis-cli to do this.