Closed selcukaltinay closed 7 months ago
It's a good question. We didn't think about custom module commands when we rewrote command.h, but of course we need to support this.
I think we need to provide a way to extend the command definition, either at compile time or in runtime. We have to think about the best way to do this.
In the meantime, there is one workaround: You can use redisClusterGetNodeByKey
and then redisClusterCommandToNode
(or the similar functions for async API) to send any command to the specified node.
Thanks for answer. I tried to make your suggestions like this
std::string key = "{my_key}"; cluster_node node = redisClusterGetNodeByKey(cc, key); reply = (redisReply *) redisClusterCommandToNode(cc, node, strCommand.c_str());
But I'm taking "Resource Temporarily Unavailable" error when I try to run the program
Thanks again
I'm not very good with C++ but I guess key
needs to be a char *
instead of a std:string
. Can this be the problem?
Or maybe "Resource Temporarily Unavailable" means there is a temporary network problem, your Redis cluster is not available?
Maybe its a copy&paste error but you should need to give key.c_str()
to redisClusterGetNodeByKey()
too,
then if you are using the async api (?) you should use redisClusterAsyncCommandToNode()
(already mentioned above.. but just mentioning it again since you see a EAGAIN "Resource Temporarily Unavailable" )
The resource unavailable problem fixed with using placeholders as %s, command instead of giving full string with c_str method. And also suggested work around worked fine. Thanks for answers
Ah, the docs mentions that command is separated by spaces, but it is not very clear. Perhaps we should also add an example that you can't do
// Wrong:
reply = redisClusterCommand(clustercontext, "SET foo \"Hello my name is Mr. Hankey\"");
// Correct:
reply = redisClusterCommand(clustercontext, "SET foo %s", "Hello my name is Mr. Hankey");
This could be improved in hiredis README as well...
Anyway, this issue is resolved so I'm closing it.
I'm trying to use redis modules with hiredis-cluster. In previous version of hiredis-cluster, it is possible to add commands to command.h in order to use the redis commands like FT.CREATE which comes from redisearch. But in the last version, there is a script which is named as gencommands.py to produce cmddef.h. As far as I know, I need to add commands to this file to produce QUERY to send redis server. But I couldn't have make it for RediSearch and RedisJSON. I'm giving the json which is located in redisjson and redisearch as an argument my I'm taking an error. How can I use redisearch and redisjson with hiredis-cluster?