-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Description
The API for RedisModule_HashGet uses C varargs. For our use case, we would like to call it with a list of keys to retrieve that is not known at compile time (specifically from redismodule-rs, which would take a vector of keys to retrieve and then call the HashGet API with arguments based on this vector).
Unfortunately there’s no standard way of passing a list or array to a function that uses C varargs. The usual solution to this is having a function accepts a pointer to an array, and wrap that function with a higher level one that uses varargs. This is the approach used by the standard execl(3) vs execv(3) POSIX APIs, or by many printf implementations (vprintf).
A description of the problem that the feature will solve, or the use-case with which the feature will be used.
We suggest adding a couple of APIs to address this:
int RM_HashGetV(RedisModuleKey *key, int flags, StringRedisModule *const fields[], StringRedisModule *vals[]);
int RM_HashSetV(RedisModuleKey *key, int flags, StringRedisModule *const fields[], const StringRedisModule *vals[]);
(the V suffix was inspired by execv and similar functions, we could come up with a better name).