Closed arnaud-soulard closed 8 months ago
hiredis-cluster needs to know to which node to send the command. Normally it uses the key in a command to choose the node. For FLUSHALL I guess you want to send it to all nodes? Or just one?
You can use the node iterator to get each node. Then you can use redisClusterCommandToNode to send the command to each node. See https://github.com/Nordix/hiredis-cluster#cluster-node-iterator. You can also use redisClusterGetNodeByKey to get a node responsible for some key.
Okay, you're right, thank you very much for your response. My intention was to send the flushall command to all nodes.
I am currently using the library, especially the function redisClusterCommand(). I works fine when using commands with keys, for instance:
"SET" "foo" "bar"
But, when I try to send a command without keys:
FLUSHALL
I get the following error message:
Error: No keys in command(must have keys for redis cluster mode)
This message comes from your library (in hircluster.c, command_format_by_slot function). As I am able to execute a "FLUSHALL" in a cluster when connected through redis-cli, I guess we should be able to do the same using your library.
I encounted the same issue using commands such as: PING, INFO
Did I miss something, do you see a workaround for me? Thanks