Passing A Vector of RedisModuleString to RedisModule_Call
While building Redis Too (a recommendation engine module for Redis), I spent a good bit of time (and strands of hair) figuring out how to pass a variable number of arguments to a Redis command like “SUNION”.
The format specified of the
RedisModule_Call function accepts ‘v’ to denote “a vector of RedisModuleString”. But to use it, you need to pass two arguments to
RedisModule_Call: the array of
RedisModuleString and the size of the array.
Assuming you have the array
args defined as
RedisModuleString **args, and the size of the array
size_t n, you can call
RedisModule_Call as follows:
You can also mix it with other arguments in the call:
This post is 1st of my #100DaysToOffload challenge. Want to get involved? Find out more at 100daystooffload.com.
comments powered by Disqus