From the documentation this seems how flushall would work but in practice it is not working that way. When I use the command flushall
it only flushes the keys from the db instance the cli is assigned to.
Delete all the keys of all the existing databases, not just the currently selected one. This command never fails.
The time-complexity for this operation is O(N), N being the number of keys in all existing databases.
For example if my cluster redis-cli has started and I search for a key and the node cli changes from 7000 to 7002 corresponding with the key that the hash is located i.e. server 7002 and then do a flush all it will delete the key per that server.
However, the other keys remain.
Is there a way to flushall meaning delete all keys across all masters and slaves?
Yes. You can use the cli's --cluster
switch with the call
command - it will execute the provided command on each of the cluster's master nodes (and will replicate, as FLUSHALL
is a write command, to their respective slaves).
This should do it:
$ redis-cli --cluster call --cluster-only-masters <one-of-the-nodes-address>:<its-port> FLUSHALL