From bf48df17d22975e986fbb525cbc02c0ad085b939 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 22 Mar 2024 17:18:07 +0100 Subject: [PATCH] all: s/RedisModule/RedictModule/g This is a fairly naive change, but it seems to be correct. Will review more carefully later, as well as adding a shim for source-level Redis Modules compatibility. Signed-off-by: Drew DeVault --- README.md | 3 +- src/aof.c | 2 +- src/call_reply.h | 2 +- src/commands.h | 2 +- src/config.c | 4 +- src/db.c | 4 +- src/debug.c | 2 +- src/module.c | 2380 ++++++++++++++++++------------------ src/modules/helloacl.c | 94 +- src/modules/helloblock.c | 110 +- src/modules/hellocluster.c | 52 +- src/modules/hellodict.c | 56 +- src/modules/hellohook.c | 28 +- src/modules/hellotimer.c | 18 +- src/modules/hellotype.c | 170 +-- src/modules/helloworld.c | 400 +++--- src/networking.c | 2 +- src/rdb.c | 8 +- src/redictmodule.h | 1106 ++++++++--------- src/server.c | 4 +- src/server.h | 74 +- src/tls.c | 10 +- 22 files changed, 2266 insertions(+), 2265 deletions(-) diff --git a/README.md b/README.md index 3760cfce5..c76ca51ba 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ More details to come in a later announcement. * [x] REUSE for license management * [x] Rename source files * [x] Add redict:// protocol support -* [ ] Fork Redis modules API +* [x] Fork Redis modules API + * [ ] Build compatibility shim * [x] Rename Lua API symbols (w/compat shim) * [ ] Update test suite to use redict instead of redis * [x] Update strings diff --git a/src/aof.c b/src/aof.c index 7ec41cc09..c5f28b301 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2189,7 +2189,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) { * that is exported by a module and is not handled by Redict itself. * The function returns 0 on error, 1 on success. */ int rewriteModuleObject(rio *r, robj *key, robj *o, int dbid) { - RedisModuleIO io; + RedictModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitIOContext(io,mt,r,key,dbid); diff --git a/src/call_reply.h b/src/call_reply.h index 9de09ba25..e3ff6a540 100644 --- a/src/call_reply.h +++ b/src/call_reply.h @@ -11,7 +11,7 @@ #include "resp_parser.h" typedef struct CallReply CallReply; -typedef void (*RedisModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data); +typedef void (*RedictModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data); CallReply *callReplyCreate(sds reply, list *deferred_error_list, void *private_data); CallReply *callReplyCreateError(sds reply, void *private_data); diff --git a/src/commands.h b/src/commands.h index cf654d1ae..ade8a05e6 100644 --- a/src/commands.h +++ b/src/commands.h @@ -25,7 +25,7 @@ typedef enum { #define CMD_ARG_MULTIPLE (1<<1) #define CMD_ARG_MULTIPLE_TOKEN (1<<2) -/* Must be compatible with RedisModuleCommandArg. See moduleCopyCommandArgs. */ +/* Must be compatible with RedictModuleCommandArg. See moduleCopyCommandArgs. */ typedef struct redictCommandArg { const char *name; redisCommandArgType type; diff --git a/src/config.c b/src/config.c index 02ef72226..47831f666 100644 --- a/src/config.c +++ b/src/config.c @@ -912,7 +912,7 @@ void configSetCommand(client *c) { goto err; } - RedisModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; + RedictModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; moduleFireServerEvent(REDISMODULE_EVENT_CONFIG, REDISMODULE_SUBEVENT_CONFIG_CHANGE, &cc); addReply(c,shared.ok); goto end; @@ -1566,7 +1566,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { dictIterator *di = dictGetIterator(modules); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); line = sdsnew("loadmodule "); line = sdscatsds(line, module->loadmod->path); for (int i = 0; i < module->loadmod->argc; i++) { diff --git a/src/db.c b/src/db.c index c02440d0c..9e0558aa3 100644 --- a/src/db.c +++ b/src/db.c @@ -502,7 +502,7 @@ long long emptyDbStructure(redictDb *dbarray, int dbnum, int async, long long emptyData(int dbnum, int flags, void(callback)(dict*)) { int async = (flags & EMPTYDB_ASYNC); int with_functions = !(flags & EMPTYDB_NOFUNCTIONS); - RedisModuleFlushInfoV1 fi = {REDISMODULE_FLUSHINFO_VERSION,!async,dbnum}; + RedictModuleFlushInfoV1 fi = {REDISMODULE_FLUSHINFO_VERSION,!async,dbnum}; long long removed = 0; if (dbnum < -1 || dbnum >= server.dbnum) { @@ -1657,7 +1657,7 @@ void swapdbCommand(client *c) { addReplyError(c,"DB index is out of range"); return; } else { - RedisModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2}; + RedictModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2}; moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si); server.dirty++; addReply(c,shared.ok); diff --git a/src/debug.c b/src/debug.c index f4f0f84d7..c7a228ac1 100644 --- a/src/debug.c +++ b/src/debug.c @@ -236,7 +236,7 @@ void xorObjectDigest(redictDb *db, robj *keyobj, unsigned char *digest, robj *o) } streamIteratorStop(&si); } else if (o->type == OBJ_MODULE) { - RedisModuleDigest md = {{0},{0},keyobj,db->id}; + RedictModuleDigest md = {{0},{0},keyobj,db->id}; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitDigestContext(md); diff --git a/src/module.c b/src/module.c index 8091e03b1..23122443e 100644 --- a/src/module.c +++ b/src/module.c @@ -25,7 +25,7 @@ * the generated a API documentation. * * The documentation comments may contain markdown formatting. Some automatic - * replacements are done, such as the replacement of RM with RedisModule in + * replacements are done, such as the replacement of RM with RedictModule in * function names. For details, see the script src/modules/gendoc.rb. * -------------------------------------------------------------------------- */ @@ -50,8 +50,8 @@ * pointers that have an API the module can call with them) * -------------------------------------------------------------------------- */ -struct RedisModuleInfoCtx { - struct RedisModule *module; +struct RedictModuleInfoCtx { + struct RedictModule *module; dict *requested_sections; sds info; /* info string we collected so far */ int sections; /* number of sections we collected so far */ @@ -63,13 +63,13 @@ struct RedisModuleInfoCtx { * the server.sharedapi dictionary, mapping names of APIs exported by * modules for other modules to use, to their structure specifying the * function pointer that can be called. */ -struct RedisModuleSharedAPI { +struct RedictModuleSharedAPI { void *func; - RedisModule *module; + RedictModule *module; }; -typedef struct RedisModuleSharedAPI RedisModuleSharedAPI; +typedef struct RedictModuleSharedAPI RedictModuleSharedAPI; -dict *modules; /* Hash table of modules. SDS -> RedisModule ptr.*/ +dict *modules; /* Hash table of modules. SDS -> RedictModule ptr.*/ /* Entries in the context->amqueue array, representing objects to free * when the callback returns. */ @@ -102,12 +102,12 @@ struct AutoMemEntry { #define REDISMODULE_POOL_ALLOC_MIN_SIZE (1024*8) #define REDISMODULE_POOL_ALLOC_ALIGN (sizeof(void*)) -typedef struct RedisModulePoolAllocBlock { +typedef struct RedictModulePoolAllocBlock { uint32_t size; uint32_t used; - struct RedisModulePoolAllocBlock *next; + struct RedictModulePoolAllocBlock *next; char memory[]; -} RedisModulePoolAllocBlock; +} RedictModulePoolAllocBlock; /* This structure represents the context in which Redis modules operate. * Most APIs module can access, get a pointer to the context, so that the API @@ -117,14 +117,14 @@ typedef struct RedisModulePoolAllocBlock { * Note that not all the context structure is always filled with actual values * but only the fields needed in a given context. */ -struct RedisModuleBlockedClient; -struct RedisModuleUser; +struct RedictModuleBlockedClient; +struct RedictModuleUser; -struct RedisModuleCtx { +struct RedictModuleCtx { void *getapifuncptr; /* NOTE: Must be the first field. */ - struct RedisModule *module; /* Module reference. */ + struct RedictModule *module; /* Module reference. */ client *client; /* Client calling a command. */ - struct RedisModuleBlockedClient *blocked_client; /* Blocked client for + struct RedictModuleBlockedClient *blocked_client; /* Blocked client for thread safe context. */ struct AutoMemEntry *amqueue; /* Auto memory queue of objects to free. */ int amqueue_len; /* Number of slots in amqueue. */ @@ -133,7 +133,7 @@ struct RedisModuleCtx { void **postponed_arrays; /* To set with RM_ReplySetArrayLength(). */ int postponed_arrays_count; /* Number of entries in postponed_arrays. */ void *blocked_privdata; /* Privdata set when unblocking a client. */ - RedisModuleString *blocked_ready_key; /* Key ready when the reply callback + RedictModuleString *blocked_ready_key; /* Key ready when the reply callback gets called for clients blocked on keys. */ @@ -141,13 +141,13 @@ struct RedisModuleCtx { * REDISMODULE_CTX_CHANNEL_POS_REQUEST flag set. */ getKeysResult *keys_result; - struct RedisModulePoolAllocBlock *pa_head; + struct RedictModulePoolAllocBlock *pa_head; long long next_yield_time; - const struct RedisModuleUser *user; /* RedisModuleUser commands executed via + const struct RedictModuleUser *user; /* RedictModuleUser commands executed via RM_Call should be executed as, if set */ }; -typedef struct RedisModuleCtx RedisModuleCtx; +typedef struct RedictModuleCtx RedictModuleCtx; #define REDISMODULE_CTX_NONE (0) #define REDISMODULE_CTX_AUTO_MEMORY (1<<0) @@ -165,8 +165,8 @@ typedef struct RedisModuleCtx RedisModuleCtx; /* This represents a Redis key opened with RM_OpenKey(). */ -struct RedisModuleKey { - RedisModuleCtx *ctx; +struct RedictModuleKey { + RedictModuleCtx *ctx; redictDb *db; robj *key; /* Key name object. */ robj *value; /* Value object, or NULL if the key was not found. */ @@ -199,7 +199,7 @@ struct RedisModuleKey { } u; }; -/* RedisModuleKey 'ztype' values. */ +/* RedictModuleKey 'ztype' values. */ #define REDISMODULE_ZSET_RANGE_NONE 0 /* This must always be 0. */ #define REDISMODULE_ZSET_RANGE_LEX 1 #define REDISMODULE_ZSET_RANGE_SCORE 2 @@ -207,18 +207,18 @@ struct RedisModuleKey { /* Function pointer type of a function representing a command inside * a Redis module. */ -struct RedisModuleBlockedClient; -typedef int (*RedisModuleCmdFunc) (RedisModuleCtx *ctx, void **argv, int argc); -typedef int (*RedisModuleAuthCallback)(RedisModuleCtx *ctx, void *username, void *password, RedisModuleString **err); -typedef void (*RedisModuleDisconnectFunc) (RedisModuleCtx *ctx, struct RedisModuleBlockedClient *bc); +struct RedictModuleBlockedClient; +typedef int (*RedictModuleCmdFunc) (RedictModuleCtx *ctx, void **argv, int argc); +typedef int (*RedictModuleAuthCallback)(RedictModuleCtx *ctx, void *username, void *password, RedictModuleString **err); +typedef void (*RedictModuleDisconnectFunc) (RedictModuleCtx *ctx, struct RedictModuleBlockedClient *bc); /* This struct holds the information about a command registered by a module.*/ struct RedictModuleCommand { - struct RedisModule *module; - RedisModuleCmdFunc func; + struct RedictModule *module; + RedictModuleCmdFunc func; struct redictCommand *rediscmd; }; -typedef struct RedictModuleCommand RedisModuleCommand; +typedef struct RedictModuleCommand RedictModuleCommand; #define REDISMODULE_REPLYFLAG_NONE 0 #define REDISMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */ @@ -228,29 +228,29 @@ typedef struct RedictModuleCommand RedisModuleCommand; /* Reply of RM_Call() function. The function is filled in a lazy * way depending on the function called on the reply structure. By default * only the type, proto and protolen are filled. */ -typedef struct CallReply RedisModuleCallReply; +typedef struct CallReply RedictModuleCallReply; /* Structure to hold the module auth callback & the Module implementing it. */ -typedef struct RedisModuleAuthCtx { - struct RedisModule *module; - RedisModuleAuthCallback auth_cb; -} RedisModuleAuthCtx; +typedef struct RedictModuleAuthCtx { + struct RedictModule *module; + RedictModuleAuthCallback auth_cb; +} RedictModuleAuthCtx; /* Structure representing a blocked client. We get a pointer to such * an object when blocking from modules. */ -typedef struct RedisModuleBlockedClient { +typedef struct RedictModuleBlockedClient { client *client; /* Pointer to the blocked client. or NULL if the client was destroyed during the life of this object. */ - RedisModule *module; /* Module blocking the client. */ - RedisModuleCmdFunc reply_callback; /* Reply callback on normal completion.*/ - RedisModuleAuthCallback auth_reply_cb; /* Reply callback on completing blocking + RedictModule *module; /* Module blocking the client. */ + RedictModuleCmdFunc reply_callback; /* Reply callback on normal completion.*/ + RedictModuleAuthCallback auth_reply_cb; /* Reply callback on completing blocking module authentication. */ - RedisModuleCmdFunc timeout_callback; /* Reply callback on timeout. */ - RedisModuleDisconnectFunc disconnect_callback; /* Called on disconnection.*/ - void (*free_privdata)(RedisModuleCtx*,void*);/* privdata cleanup callback.*/ + RedictModuleCmdFunc timeout_callback; /* Reply callback on timeout. */ + RedictModuleDisconnectFunc disconnect_callback; /* Called on disconnection.*/ + void (*free_privdata)(RedictModuleCtx*,void*);/* privdata cleanup callback.*/ void *privdata; /* Module private data that may be used by the reply or timeout callback. It is set via the - RedisModule_UnblockClient() API. */ + RedictModule_UnblockClient() API. */ client *thread_safe_ctx_client; /* Fake client to be used for thread safe context so that no lock is required. */ client *reply_client; /* Fake client used to accumulate replies @@ -261,7 +261,7 @@ typedef struct RedisModuleBlockedClient { monotime background_timer; /* Timer tracking the start of background work */ uint64_t background_duration; /* Current command background time duration. Used for measuring latency of blocking cmds */ -} RedisModuleBlockedClient; +} RedictModuleBlockedClient; /* This is a list of Module Auth Contexts. Each time a Module registers a callback, a new ctx is * added to this list. Multiple modules can register auth callbacks and the same Module can have @@ -286,33 +286,33 @@ static size_t moduleTempClientMinCount = 0; /* Min client count in pool since static pthread_mutex_t moduleGIL = PTHREAD_MUTEX_INITIALIZER; /* Function pointer type for keyspace event notification subscriptions from modules. */ -typedef int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key); +typedef int (*RedictModuleNotificationFunc) (RedictModuleCtx *ctx, int type, const char *event, RedictModuleString *key); /* Function pointer type for post jobs */ -typedef void (*RedisModulePostNotificationJobFunc) (RedisModuleCtx *ctx, void *pd); +typedef void (*RedictModulePostNotificationJobFunc) (RedictModuleCtx *ctx, void *pd); /* Keyspace notification subscriber information. * See RM_SubscribeToKeyspaceEvents() for more information. */ -typedef struct RedisModuleKeyspaceSubscriber { +typedef struct RedictModuleKeyspaceSubscriber { /* The module subscribed to the event */ - RedisModule *module; + RedictModule *module; /* Notification callback in the module*/ - RedisModuleNotificationFunc notify_callback; + RedictModuleNotificationFunc notify_callback; /* A bit mask of the events the module is interested in */ int event_mask; /* Active flag set on entry, to avoid reentrant subscribers * calling themselves */ int active; -} RedisModuleKeyspaceSubscriber; +} RedictModuleKeyspaceSubscriber; -typedef struct RedisModulePostExecUnitJob { +typedef struct RedictModulePostExecUnitJob { /* The module subscribed to the event */ - RedisModule *module; - RedisModulePostNotificationJobFunc callback; + RedictModule *module; + RedictModulePostNotificationJobFunc callback; void *pd; void (*free_pd)(void*); int dbid; -} RedisModulePostExecUnitJob; +} RedictModulePostExecUnitJob; /* The module keyspace notification subscribers list */ static list *moduleKeyspaceSubscribers; @@ -321,46 +321,46 @@ static list *moduleKeyspaceSubscribers; static list *modulePostExecUnitJobs; /* Data structures related to the exported dictionary data structure. */ -typedef struct RedisModuleDict { +typedef struct RedictModuleDict { rax *rax; /* The radix tree. */ -} RedisModuleDict; +} RedictModuleDict; -typedef struct RedisModuleDictIter { - RedisModuleDict *dict; +typedef struct RedictModuleDictIter { + RedictModuleDict *dict; raxIterator ri; -} RedisModuleDictIter; +} RedictModuleDictIter; -typedef struct RedisModuleCommandFilterCtx { - RedisModuleString **argv; +typedef struct RedictModuleCommandFilterCtx { + RedictModuleString **argv; int argv_len; int argc; client *c; -} RedisModuleCommandFilterCtx; +} RedictModuleCommandFilterCtx; -typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter); +typedef void (*RedictModuleCommandFilterFunc) (RedictModuleCommandFilterCtx *filter); -typedef struct RedisModuleCommandFilter { +typedef struct RedictModuleCommandFilter { /* The module that registered the filter */ - RedisModule *module; + RedictModule *module; /* Filter callback function */ - RedisModuleCommandFilterFunc callback; + RedictModuleCommandFilterFunc callback; /* REDISMODULE_CMDFILTER_* flags */ int flags; -} RedisModuleCommandFilter; +} RedictModuleCommandFilter; /* Registered filters */ static list *moduleCommandFilters; -typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*RedictModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); -static struct RedisModuleForkInfo { - RedisModuleForkDoneHandler done_handler; +static struct RedictModuleForkInfo { + RedictModuleForkDoneHandler done_handler; void* done_handler_user_data; } moduleForkInfo = {0}; -typedef struct RedisModuleServerInfoData { +typedef struct RedictModuleServerInfoData { rax *rax; /* parsed info data. */ -} RedisModuleServerInfoData; +} RedictModuleServerInfoData; /* Flags for moduleCreateArgvFromUserFormat(). */ #define REDISMODULE_ARGV_REPLICATE (1<<0) @@ -388,101 +388,101 @@ typedef struct RedisModuleServerInfoData { * the start and end of an RDB or AOF save, the change of role in replication, * and similar other events. */ -typedef struct RedisModuleEventListener { - RedisModule *module; - RedisModuleEvent event; - RedisModuleEventCallback callback; -} RedisModuleEventListener; +typedef struct RedictModuleEventListener { + RedictModule *module; + RedictModuleEvent event; + RedictModuleEventCallback callback; +} RedictModuleEventListener; -list *RedisModule_EventListeners; /* Global list of all the active events. */ +list *RedictModule_EventListeners; /* Global list of all the active events. */ /* Data structures related to the redis module users */ /* This is the object returned by RM_CreateModuleUser(). The module API is * able to create users, set ACLs to such users, and later authenticate * clients using such newly created users. */ -typedef struct RedisModuleUser { +typedef struct RedictModuleUser { user *user; /* Reference to the real redis user */ int free_user; /* Indicates that user should also be freed when this object is freed */ -} RedisModuleUser; +} RedictModuleUser; /* This is a structure used to export some meta-information such as dbid to the module. */ -typedef struct RedisModuleKeyOptCtx { +typedef struct RedictModuleKeyOptCtx { struct redictObject *from_key, *to_key; /* Optional name of key processed, NULL when unknown. In most cases, only 'from_key' is valid, but in callbacks such as `copy2`, both 'from_key' and 'to_key' are valid. */ int from_dbid, to_dbid; /* The dbid of the key being processed, -1 when unknown. In most cases, only 'from_dbid' is valid, but in callbacks such as `copy2`, 'from_dbid' and 'to_dbid' are both valid. */ -} RedisModuleKeyOptCtx; +} RedictModuleKeyOptCtx; /* Data structures related to redis module configurations */ /* The function signatures for module config get callbacks. These are identical to the ones exposed in redictmodule.h. */ -typedef RedisModuleString * (*RedisModuleConfigGetStringFunc)(const char *name, void *privdata); -typedef long long (*RedisModuleConfigGetNumericFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetBoolFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetEnumFunc)(const char *name, void *privdata); +typedef RedictModuleString * (*RedictModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*RedictModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*RedictModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*RedictModuleConfigGetEnumFunc)(const char *name, void *privdata); /* The function signatures for module config set callbacks. These are identical to the ones exposed in redictmodule.h. */ -typedef int (*RedisModuleConfigSetStringFunc)(const char *name, RedisModuleString *val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedisModuleString **err); +typedef int (*RedictModuleConfigSetStringFunc)(const char *name, RedictModuleString *val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedictModuleString **err); /* Apply signature, identical to redictmodule.h */ -typedef int (*RedisModuleConfigApplyFunc)(RedisModuleCtx *ctx, void *privdata, RedisModuleString **err); +typedef int (*RedictModuleConfigApplyFunc)(RedictModuleCtx *ctx, void *privdata, RedictModuleString **err); /* Struct representing a module config. These are stored in a list in the module struct */ struct ModuleConfig { sds name; /* Name of config without the module name appended to the front */ void *privdata; /* Optional data passed into the module config callbacks */ union get_fn { /* The get callback specified by the module */ - RedisModuleConfigGetStringFunc get_string; - RedisModuleConfigGetNumericFunc get_numeric; - RedisModuleConfigGetBoolFunc get_bool; - RedisModuleConfigGetEnumFunc get_enum; + RedictModuleConfigGetStringFunc get_string; + RedictModuleConfigGetNumericFunc get_numeric; + RedictModuleConfigGetBoolFunc get_bool; + RedictModuleConfigGetEnumFunc get_enum; } get_fn; union set_fn { /* The set callback specified by the module */ - RedisModuleConfigSetStringFunc set_string; - RedisModuleConfigSetNumericFunc set_numeric; - RedisModuleConfigSetBoolFunc set_bool; - RedisModuleConfigSetEnumFunc set_enum; + RedictModuleConfigSetStringFunc set_string; + RedictModuleConfigSetNumericFunc set_numeric; + RedictModuleConfigSetBoolFunc set_bool; + RedictModuleConfigSetEnumFunc set_enum; } set_fn; - RedisModuleConfigApplyFunc apply_fn; - RedisModule *module; + RedictModuleConfigApplyFunc apply_fn; + RedictModule *module; }; -typedef struct RedisModuleAsyncRMCallPromise{ +typedef struct RedictModuleAsyncRMCallPromise{ size_t ref_count; void *private_data; - RedisModule *module; - RedisModuleOnUnblocked on_unblocked; + RedictModule *module; + RedictModuleOnUnblocked on_unblocked; client *c; - RedisModuleCtx *ctx; -} RedisModuleAsyncRMCallPromise; + RedictModuleCtx *ctx; +} RedictModuleAsyncRMCallPromise; /* -------------------------------------------------------------------------- * Prototypes * -------------------------------------------------------------------------- */ -void RM_FreeCallReply(RedisModuleCallReply *reply); -void RM_CloseKey(RedisModuleKey *key); -void autoMemoryCollect(RedisModuleCtx *ctx); +void RM_FreeCallReply(RedictModuleCallReply *reply); +void RM_CloseKey(RedictModuleKey *key); +void autoMemoryCollect(RedictModuleCtx *ctx); robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int *argcp, int *flags, va_list ap); -void RM_ZsetRangeStop(RedisModuleKey *kp); -static void zsetKeyReset(RedisModuleKey *key); -static void moduleInitKeyTypeSpecific(RedisModuleKey *key); -void RM_FreeDict(RedisModuleCtx *ctx, RedisModuleDict *d); -void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data); +void RM_ZsetRangeStop(RedictModuleKey *kp); +static void zsetKeyReset(RedictModuleKey *key); +static void moduleInitKeyTypeSpecific(RedictModuleKey *key); +void RM_FreeDict(RedictModuleCtx *ctx, RedictModuleDict *d); +void RM_FreeServerInfo(RedictModuleCtx *ctx, RedictModuleServerInfoData *data); /* Helpers for RM_SetCommandInfo. */ -static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info); +static int moduleValidateCommandInfo(const RedictModuleCommandInfo *info); static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api); -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static struct redictCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); +static int moduleValidateCommandArgs(RedictModuleCommandArg *args, + const RedictModuleCommandInfoVersion *version); +static struct redictCommandArg *moduleCopyCommandArgs(RedictModuleCommandArg *args, + const RedictModuleCommandInfoVersion *version); +static redisCommandArgType moduleConvertArgType(RedictModuleCommandArgType type, int *error); static int moduleConvertArgFlags(int flags); -void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags); +void moduleCreateContext(RedictModuleCtx *out_ctx, RedictModule *module, int ctx_flags); /* Common helper functions. */ int moduleVerifyResourceName(const char *name); @@ -530,7 +530,7 @@ void *RM_TryCalloc(size_t nmemb, size_t size) { return ztrycalloc_usable(nmemb*size,NULL); } -/* Use like realloc() for memory obtained with RedisModule_Alloc(). */ +/* Use like realloc() for memory obtained with RedictModule_Alloc(). */ void* RM_Realloc(void *ptr, size_t bytes) { return zrealloc_usable(ptr,bytes,NULL); } @@ -541,14 +541,14 @@ void *RM_TryRealloc(void *ptr, size_t bytes) { return ztryrealloc_usable(ptr,bytes,NULL); } -/* Use like free() for memory obtained by RedisModule_Alloc() and - * RedisModule_Realloc(). However you should never try to free with - * RedisModule_Free() memory allocated with malloc() inside your module. */ +/* Use like free() for memory obtained by RedictModule_Alloc() and + * RedictModule_Realloc(). However you should never try to free with + * RedictModule_Free() memory allocated with malloc() inside your module. */ void RM_Free(void *ptr) { zfree(ptr); } -/* Like strdup() but returns memory allocated with RedisModule_Alloc(). */ +/* Like strdup() but returns memory allocated with RedictModule_Alloc(). */ char *RM_Strdup(const char *str) { return zstrdup(str); } @@ -558,8 +558,8 @@ char *RM_Strdup(const char *str) { * -------------------------------------------------------------------------- */ /* Release the chain of blocks used for pool allocations. */ -void poolAllocRelease(RedisModuleCtx *ctx) { - RedisModulePoolAllocBlock *head = ctx->pa_head, *next; +void poolAllocRelease(RedictModuleCtx *ctx) { + RedictModulePoolAllocBlock *head = ctx->pa_head, *next; while(head != NULL) { next = head->next; @@ -581,9 +581,9 @@ void poolAllocRelease(RedisModuleCtx *ctx) { * pool allocator is not a good idea. * * The function returns NULL if `bytes` is 0. */ -void *RM_PoolAlloc(RedisModuleCtx *ctx, size_t bytes) { +void *RM_PoolAlloc(RedictModuleCtx *ctx, size_t bytes) { if (bytes == 0) return NULL; - RedisModulePoolAllocBlock *b = ctx->pa_head; + RedictModulePoolAllocBlock *b = ctx->pa_head; size_t left = b ? b->size - b->used : 0; /* Fix alignment. */ @@ -630,7 +630,7 @@ client *moduleAllocTempClient(void) { return c; } -static void freeRedisModuleAsyncRMCallPromise(RedisModuleAsyncRMCallPromise *promise) { +static void freeRedictModuleAsyncRMCallPromise(RedictModuleAsyncRMCallPromise *promise) { if (--promise->ref_count > 0) { return; } @@ -655,9 +655,9 @@ void moduleReleaseTempClient(client *c) { c->user = NULL; /* Root user */ c->cmd = c->lastcmd = c->realcmd = NULL; if (c->bstate.async_rm_call_handle) { - RedisModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; + RedictModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; promise->c = NULL; /* Remove the client from the promise so it will no longer be possible to abort it. */ - freeRedisModuleAsyncRMCallPromise(promise); + freeRedictModuleAsyncRMCallPromise(promise); c->bstate.async_rm_call_handle = NULL; } moduleTempClients[moduleTempClientCount++] = c; @@ -675,7 +675,7 @@ void moduleReleaseTempClient(client *c) { * 2. The key is not empty. * 3. The specified type is unknown. */ -int moduleCreateEmptyKey(RedisModuleKey *key, int type) { +int moduleCreateEmptyKey(RedictModuleKey *key, int type) { robj *obj; /* The key must be open for writing and non existing to proceed. */ @@ -704,7 +704,7 @@ int moduleCreateEmptyKey(RedisModuleKey *key, int type) { } /* Frees key->iter and sets it to NULL. */ -static void moduleFreeKeyIterator(RedisModuleKey *key) { +static void moduleFreeKeyIterator(RedictModuleKey *key) { serverAssert(key->iter != NULL); switch (key->value->type) { case OBJ_LIST: listTypeReleaseIterator(key->iter); break; @@ -720,7 +720,7 @@ static void moduleFreeKeyIterator(RedisModuleKey *key) { /* Callback for listTypeTryConversion(). * Frees list iterator and sets it to NULL. */ static void moduleFreeListIterator(void *data) { - RedisModuleKey *key = (RedisModuleKey*)data; + RedictModuleKey *key = (RedictModuleKey*)data; serverAssert(key->value->type == OBJ_LIST); if (key->iter) moduleFreeKeyIterator(key); } @@ -735,7 +735,7 @@ static void moduleFreeListIterator(void *data) { * * The function returns 1 if the key value object is found empty and is * deleted, otherwise 0 is returned. */ -int moduleDelKeyIfEmpty(RedisModuleKey *key) { +int moduleDelKeyIfEmpty(RedictModuleKey *key) { if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL) return 0; int isempty; robj *o = key->value; @@ -763,7 +763,7 @@ int moduleDelKeyIfEmpty(RedisModuleKey *key) { * Service API exported to modules * * Note that all the exported APIs are called RM_ in the core - * and RedisModule_ in the module side (defined as function + * and RedictModule_ in the module side (defined as function * pointers in redictmodule.h). In this way the dynamic linker does not * mess with our global function pointers, overriding it with the symbols * defined in the main executable having the same names. @@ -796,7 +796,7 @@ void modulePostExecutionUnitOperations(void) { } /* Free the context after the user function was called. */ -void moduleFreeContext(RedisModuleCtx *ctx) { +void moduleFreeContext(RedictModuleCtx *ctx) { /* See comment in moduleCreateContext */ if (!(ctx->flags & (REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_COMMAND))) { exitExecutionUnit(); @@ -809,8 +809,8 @@ void moduleFreeContext(RedisModuleCtx *ctx) { ctx->postponed_arrays_count = 0; serverLog(LL_WARNING, "API misuse detected in module %s: " - "RedisModule_ReplyWith*(REDISMODULE_POSTPONED_LEN) " - "not matched by the same number of RedisModule_SetReply*Len() " + "RedictModule_ReplyWith*(REDISMODULE_POSTPONED_LEN) " + "not matched by the same number of RedictModule_SetReply*Len() " "calls.", ctx->module->name); } @@ -824,7 +824,7 @@ void moduleFreeContext(RedisModuleCtx *ctx) { freeClient(ctx->client); } -static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { +static CallReply *moduleParseReply(client *c, RedictModuleCtx *ctx) { /* Convert the result of the Redis command into a module reply. */ sds proto = sdsnewlen(c->buf,c->bufpos); c->bufpos = 0; @@ -840,10 +840,10 @@ static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { } void moduleCallCommandUnblockedHandler(client *c) { - RedisModuleCtx ctx; - RedisModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; + RedictModuleCtx ctx; + RedictModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; serverAssert(promise); - RedisModule *module = promise->module; + RedictModule *module = promise->module; if (!promise->on_unblocked) { moduleReleaseTempClient(c); return; /* module did not set any unblock callback. */ @@ -866,8 +866,8 @@ void moduleCallCommandUnblockedHandler(client *c) { * RM_GetDetachedThreadSafeContext) we do not bump up the nesting level * because we only need to track of nesting level in the main thread * (only the main thread uses propagatePendingCommands) */ -void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags) { - memset(out_ctx, 0 ,sizeof(RedisModuleCtx)); +void moduleCreateContext(RedictModuleCtx *out_ctx, RedictModule *module, int ctx_flags) { + memset(out_ctx, 0 ,sizeof(RedictModuleCtx)); out_ctx->getapifuncptr = (void*)(unsigned long)&RM_GetApi; out_ctx->module = module; out_ctx->flags = ctx_flags; @@ -902,9 +902,9 @@ void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_f /* This Redis command binds the normal Redis command invocation with commands * exported by modules. */ -void RedisModuleCommandDispatcher(client *c) { - RedisModuleCommand *cp = c->cmd->module_cmd; - RedisModuleCtx ctx; +void RedictModuleCommandDispatcher(client *c) { + RedictModuleCommand *cp = c->cmd->module_cmd; + RedictModuleCtx ctx; moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_COMMAND); ctx.client = c; @@ -936,10 +936,10 @@ void RedisModuleCommandDispatcher(client *c) { * * In order to accomplish its work, the module command is called, flagging * the context in a way that the command can recognize this is a special - * "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */ + * "get keys" call by calling RedictModule_IsKeysPositionRequest(ctx). */ int moduleGetCommandKeysViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; + RedictModuleCommand *cp = cmd->module_cmd; + RedictModuleCtx ctx; moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST); /* Initialize getKeysResult */ @@ -958,8 +958,8 @@ int moduleGetCommandKeysViaAPI(struct redictCommand *cmd, robj **argv, int argc, * moduleGetCommandKeysViaAPI, for modules that declare "getchannels-api" * during registration. Unlike keys, this is the only way to declare channels. */ int moduleGetCommandChannelsViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; + RedictModuleCommand *cp = cmd->module_cmd; + RedictModuleCtx ctx; moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST); /* Initialize getKeysResult */ @@ -984,14 +984,14 @@ int moduleGetCommandChannelsViaAPI(struct redictCommand *cmd, robj **argv, int a /* Return non-zero if a module command, that was declared with the * flag "getkeys-api", is called in a special way to get the keys positions * and not to get executed. Otherwise zero is returned. */ -int RM_IsKeysPositionRequest(RedisModuleCtx *ctx) { +int RM_IsKeysPositionRequest(RedictModuleCtx *ctx) { return (ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) != 0; } /* When a module command is called in order to obtain the position of * keys, since it was flagged as "getkeys-api" during the registration, * the command implementation checks for this special call using the - * RedisModule_IsKeysPositionRequest() API and uses this function in + * RedictModule_IsKeysPositionRequest() API and uses this function in * order to report keys. * * The supported flags are the ones used by RM_SetCommandInfo, see REDISMODULE_CMD_KEY_*. @@ -999,16 +999,16 @@ int RM_IsKeysPositionRequest(RedisModuleCtx *ctx) { * * The following is an example of how it could be used: * - * if (RedisModule_IsKeysPositionRequest(ctx)) { - * RedisModule_KeyAtPosWithFlags(ctx, 2, REDISMODULE_CMD_KEY_RO | REDISMODULE_CMD_KEY_ACCESS); - * RedisModule_KeyAtPosWithFlags(ctx, 1, REDISMODULE_CMD_KEY_RW | REDISMODULE_CMD_KEY_UPDATE | REDISMODULE_CMD_KEY_ACCESS); + * if (RedictModule_IsKeysPositionRequest(ctx)) { + * RedictModule_KeyAtPosWithFlags(ctx, 2, REDISMODULE_CMD_KEY_RO | REDISMODULE_CMD_KEY_ACCESS); + * RedictModule_KeyAtPosWithFlags(ctx, 1, REDISMODULE_CMD_KEY_RW | REDISMODULE_CMD_KEY_UPDATE | REDISMODULE_CMD_KEY_ACCESS); * } * * Note: in the example above the get keys API could have been handled by key-specs (preferred). * Implementing the getkeys-api is required only when is it not possible to declare key-specs that cover all keys. * */ -void RM_KeyAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { +void RM_KeyAtPosWithFlags(RedictModuleCtx *ctx, int pos, int flags) { if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; @@ -1028,7 +1028,7 @@ void RM_KeyAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { /* This API existed before RM_KeyAtPosWithFlags was added, now deprecated and * can be used for compatibility with older versions, before key-specs and flags * were introduced. */ -void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) { +void RM_KeyAtPos(RedictModuleCtx *ctx, int pos) { /* Default flags require full access */ int flags = moduleConvertKeySpecsFlags(CMD_KEY_FULL_ACCESS, 0); RM_KeyAtPosWithFlags(ctx, pos, flags); @@ -1037,14 +1037,14 @@ void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) { /* Return non-zero if a module command, that was declared with the * flag "getchannels-api", is called in a special way to get the channel positions * and not to get executed. Otherwise zero is returned. */ -int RM_IsChannelsPositionRequest(RedisModuleCtx *ctx) { +int RM_IsChannelsPositionRequest(RedictModuleCtx *ctx) { return (ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) != 0; } /* When a module command is called in order to obtain the position of * channels, since it was flagged as "getchannels-api" during the * registration, the command implementation checks for this special call - * using the RedisModule_IsChannelsPositionRequest() API and uses this + * using the RedictModule_IsChannelsPositionRequest() API and uses this * function in order to report the channels. * * The supported flags are: @@ -1058,16 +1058,16 @@ int RM_IsChannelsPositionRequest(RedisModuleCtx *ctx) { * * The following is an example of how it could be used: * - * if (RedisModule_IsChannelsPositionRequest(ctx)) { - * RedisModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_SUBSCRIBE | REDISMODULE_CMD_CHANNEL_PATTERN); - * RedisModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_PUBLISH); + * if (RedictModule_IsChannelsPositionRequest(ctx)) { + * RedictModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_SUBSCRIBE | REDISMODULE_CMD_CHANNEL_PATTERN); + * RedictModule_ChannelAtPosWithFlags(ctx, 1, REDISMODULE_CMD_CHANNEL_PUBLISH); * } * * Note: One usage of declaring channels is for evaluating ACL permissions. In this context, * unsubscribing is always allowed, so commands will only be checked against subscribe and * publish permissions. This is preferred over using RM_ACLCheckChannelPermissions, since * it allows the ACLs to be checked before the command is executed. */ -void RM_ChannelAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { +void RM_ChannelAtPosWithFlags(RedictModuleCtx *ctx, int pos, int flags) { if (!(ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; @@ -1147,14 +1147,14 @@ int64_t commandFlagsFromString(char *s) { return flags; } -RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep); +RedictModuleCommand *moduleCreateCommandProxy(struct RedictModule *module, sds declared_name, sds fullname, RedictModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep); /* Register a new command in the Redis server, that will be handled by - * calling the function pointer 'cmdfunc' using the RedisModule calling + * calling the function pointer 'cmdfunc' using the RedictModule calling * convention. * * The function returns REDISMODULE_ERR in these cases: - * - If creation of module command is called outside the RedisModule_OnLoad. + * - If creation of module command is called outside the RedictModule_OnLoad. * - The specified command is already busy. * - The command name contains some chars that are not allowed. * - A set of invalid flags were passed. @@ -1162,12 +1162,12 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * Otherwise REDISMODULE_OK is returned and the new command is registered. * * This function must be called during the initialization of the module - * inside the RedisModule_OnLoad() function. Calling this function outside + * inside the RedictModule_OnLoad() function. Calling this function outside * of the initialization function is not defined. * * The command function type is the following: * - * int MyCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc); + * int MyCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc); * * And is supposed to always return REDISMODULE_OK. * @@ -1243,9 +1243,9 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * NOTE: The scheme described above serves a limited purpose and can * only be used to find keys that exist at constant indices. * For non-trivial key arguments, you may pass 0,0,0 and use - * RedisModule_SetCommandInfo to set key specs using a more advanced scheme and use - * RedisModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ -int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { + * RedictModule_SetCommandInfo to set key specs using a more advanced scheme and use + * RedictModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ +int RM_CreateCommand(RedictModuleCtx *ctx, const char *name, RedictModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!ctx->module->onload) return REDISMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; @@ -1262,7 +1262,7 @@ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc c return REDISMODULE_ERR; sds declared_name = sdsnew(name); - RedisModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep); + RedictModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep); cp->rediscmd->arity = cmdfunc ? -1 : -2; /* Default value, can be changed later via dedicated API */ serverAssert(dictAdd(server.commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK); @@ -1278,9 +1278,9 @@ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc c * * Function will take the ownership of both 'declared_name' and 'fullname' SDS. */ -RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { +RedictModuleCommand *moduleCreateCommandProxy(struct RedictModule *module, sds declared_name, sds fullname, RedictModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { struct redictCommand *rediscmd; - RedisModuleCommand *cp; + RedictModuleCommand *cp; /* Create a command "proxy", which is a structure that is referenced * in the command table, so that the generic command that works as @@ -1293,7 +1293,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec cp->rediscmd->declared_name = declared_name; /* SDS for module commands */ cp->rediscmd->fullname = fullname; cp->rediscmd->group = COMMAND_GROUP_MODULE; - cp->rediscmd->proc = RedisModuleCommandDispatcher; + cp->rediscmd->proc = RedictModuleCommandDispatcher; cp->rediscmd->flags = flags | CMD_MODULE; cp->rediscmd->module_cmd = cp; if (firstkey != 0) { @@ -1329,35 +1329,35 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * * The command is not a module command * * The command doesn't belong to the calling module */ -RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) { +RedictModuleCommand *RM_GetCommand(RedictModuleCtx *ctx, const char *name) { struct redictCommand *cmd = lookupCommandByCString(name); if (!cmd || !(cmd->flags & CMD_MODULE)) return NULL; - RedisModuleCommand *cp = cmd->module_cmd; + RedictModuleCommand *cp = cmd->module_cmd; if (cp->module != ctx->module) return NULL; return cp; } -/* Very similar to RedisModule_CreateCommand except that it is used to create +/* Very similar to RedictModule_CreateCommand except that it is used to create * a subcommand, associated with another, container, command. * * Example: If a module has a configuration command, MODULE.CONFIG, then * GET and SET should be individual subcommands, while MODULE.CONFIG is * a command, but should not be registered with a valid `funcptr`: * - * if (RedisModule_CreateCommand(ctx,"module.config",NULL,"",0,0,0) == REDISMODULE_ERR) + * if (RedictModule_CreateCommand(ctx,"module.config",NULL,"",0,0,0) == REDISMODULE_ERR) * return REDISMODULE_ERR; * - * RedisModuleCommand *parent = RedisModule_GetCommand(ctx,,"module.config"); + * RedictModuleCommand *parent = RedictModule_GetCommand(ctx,,"module.config"); * - * if (RedisModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == REDISMODULE_ERR) + * if (RedictModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == REDISMODULE_ERR) * return REDISMODULE_ERR; * - * if (RedisModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == REDISMODULE_ERR) + * if (RedictModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == REDISMODULE_ERR) * return REDISMODULE_ERR; * * Returns REDISMODULE_OK on success and REDISMODULE_ERR in case of the following errors: @@ -1365,11 +1365,11 @@ RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) { * * Error while parsing `strflags` * * Command is marked as `no-cluster` but cluster mode is enabled * * `parent` is already a subcommand (we do not allow more than one level of command nesting) - * * `parent` is a command with an implementation (RedisModuleCmdFunc) (A parent command should be a pure container of subcommands) + * * `parent` is a command with an implementation (RedictModuleCmdFunc) (A parent command should be a pure container of subcommands) * * `parent` already has a subcommand called `name` - * * Creating a subcommand is called outside of RedisModule_OnLoad. + * * Creating a subcommand is called outside of RedictModule_OnLoad. */ -int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { +int RM_CreateSubcommand(RedictModuleCommand *parent, const char *name, RedictModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!parent->module->onload) return REDISMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; @@ -1382,7 +1382,7 @@ int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModul if (parent_cmd->parent) return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */ - RedisModuleCommand *parent_cp = parent_cmd->module_cmd; + RedictModuleCommand *parent_cp = parent_cmd->module_cmd; if (parent_cp->func) return REDISMODULE_ERR; /* A parent command should be a pure container of subcommands */ @@ -1398,7 +1398,7 @@ int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModul } sds fullname = catSubCommandFullname(parent_cmd->fullname, name); - RedisModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); + RedictModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); cp->rediscmd->arity = -2; commandAddSubcommand(parent_cmd, cp->rediscmd, name); @@ -1407,23 +1407,23 @@ int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModul /* Accessors of array elements of structs where the element size is stored * separately in the version struct. */ -static RedisModuleCommandHistoryEntry * -moduleCmdHistoryEntryAt(const RedisModuleCommandInfoVersion *version, - RedisModuleCommandHistoryEntry *entries, int index) { +static RedictModuleCommandHistoryEntry * +moduleCmdHistoryEntryAt(const RedictModuleCommandInfoVersion *version, + RedictModuleCommandHistoryEntry *entries, int index) { off_t offset = index * version->sizeof_historyentry; - return (RedisModuleCommandHistoryEntry *)((char *)(entries) + offset); + return (RedictModuleCommandHistoryEntry *)((char *)(entries) + offset); } -static RedisModuleCommandKeySpec * -moduleCmdKeySpecAt(const RedisModuleCommandInfoVersion *version, - RedisModuleCommandKeySpec *keyspecs, int index) { +static RedictModuleCommandKeySpec * +moduleCmdKeySpecAt(const RedictModuleCommandInfoVersion *version, + RedictModuleCommandKeySpec *keyspecs, int index) { off_t offset = index * version->sizeof_keyspec; - return (RedisModuleCommandKeySpec *)((char *)(keyspecs) + offset); + return (RedictModuleCommandKeySpec *)((char *)(keyspecs) + offset); } -static RedisModuleCommandArg * -moduleCmdArgAt(const RedisModuleCommandInfoVersion *version, - const RedisModuleCommandArg *args, int index) { +static RedictModuleCommandArg * +moduleCmdArgAt(const RedictModuleCommandInfoVersion *version, + const RedictModuleCommandArg *args, int index) { off_t offset = index * version->sizeof_arg; - return (RedisModuleCommandArg *)((char *)(args) + offset); + return (RedictModuleCommandArg *)((char *)(args) + offset); } /* Recursively populate the args structure (setting num_args to the number of @@ -1441,10 +1441,10 @@ int populateArgsStructure(struct redictCommandArg *args) { return count; } -/* RedisModule_AddACLCategory can be used to add new ACL command categories. Category names +/* RedictModule_AddACLCategory can be used to add new ACL command categories. Category names * can only contain alphanumeric characters, underscores, or dashes. Categories can only be added - * during the RedisModule_OnLoad function. Once a category has been added, it can not be removed. - * Any module can register a command to any added categories using RedisModule_SetCommandACLCategories. + * during the RedictModule_OnLoad function. Once a category has been added, it can not be removed. + * Any module can register a command to any added categories using RedictModule_SetCommandACLCategories. * * Returns: * - REDISMODULE_OK on successfully adding the new ACL category. @@ -1455,7 +1455,7 @@ int populateArgsStructure(struct redictCommandArg *args) { * - EBUSY if the category name already exists. * - ENOMEM if the number of categories reached the max limit of 64 categories. */ -int RM_AddACLCategory(RedisModuleCtx *ctx, const char *name) { +int RM_AddACLCategory(RedictModuleCtx *ctx, const char *name) { if (!ctx->module->onload) { errno = EINVAL; return REDISMODULE_ERR; @@ -1515,7 +1515,7 @@ int64_t categoryFlagsFromString(char *aclflags) { return acl_categories_flags; } -/* RedisModule_SetCommandACLCategories can be used to set ACL categories to module +/* RedictModule_SetCommandACLCategories can be used to set ACL categories to module * commands and subcommands. The set of ACL categories should be passed as * a space separated C string 'aclflags'. * @@ -1524,10 +1524,10 @@ int64_t categoryFlagsFromString(char *aclflags) { * * On success REDISMODULE_OK is returned. On error REDISMODULE_ERR is returned. * - * This function can only be called during the RedisModule_OnLoad function. If called + * This function can only be called during the RedictModule_OnLoad function. If called * outside of this function, an error is returned. */ -int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags) { +int RM_SetCommandACLCategories(RedictModuleCommand *command, const char *aclflags) { if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR; int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0; if (categories_flags == -1) return REDISMODULE_ERR; @@ -1547,17 +1547,17 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * and fetching the command pointer using RM_GetCommand. The information can * only be set once for each command and has the following structure: * - * typedef struct RedisModuleCommandInfo { - * const RedisModuleCommandInfoVersion *version; + * typedef struct RedictModuleCommandInfo { + * const RedictModuleCommandInfoVersion *version; * const char *summary; * const char *complexity; * const char *since; - * RedisModuleCommandHistoryEntry *history; + * RedictModuleCommandHistoryEntry *history; * const char *tips; * int arity; - * RedisModuleCommandKeySpec *key_specs; - * RedisModuleCommandArg *args; - * } RedisModuleCommandInfo; + * RedictModuleCommandKeySpec *key_specs; + * RedictModuleCommandArg *args; + * } RedictModuleCommandInfo; * * All fields except `version` are optional. Explanation of the fields: * @@ -1571,7 +1571,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * - `since`: The version where the command was introduced (optional). * Note: The version specified should be the module's, not Redis version. * - * - `history`: An array of RedisModuleCommandHistoryEntry (optional), which is + * - `history`: An array of RedictModuleCommandHistoryEntry (optional), which is * a struct with the following fields: * * const char *since; @@ -1592,7 +1592,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * omitted arity field) is equivalent to -2 if the command has sub commands * and -1 otherwise. * - * - `key_specs`: An array of RedisModuleCommandKeySpec, terminated by an + * - `key_specs`: An array of RedictModuleCommandKeySpec, terminated by an * element memset to zero. This is a scheme that tries to describe the * positions of key arguments better than the old RM_CreateCommand arguments * `firstkey`, `lastkey`, `keystep` and is needed if those three are not @@ -1613,10 +1613,10 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * A key-spec has the following structure: * - * typedef struct RedisModuleCommandKeySpec { + * typedef struct RedictModuleCommandKeySpec { * const char *notes; * uint64_t flags; - * RedisModuleKeySpecBeginSearchType begin_search_type; + * RedictModuleKeySpecBeginSearchType begin_search_type; * union { * struct { * int pos; @@ -1626,7 +1626,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int startfrom; * } keyword; * } bs; - * RedisModuleKeySpecFindKeysType find_keys_type; + * RedictModuleKeySpecFindKeysType find_keys_type; * union { * struct { * int lastkey; @@ -1639,9 +1639,9 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int keystep; * } keynum; * } fk; - * } RedisModuleCommandKeySpec; + * } RedictModuleCommandKeySpec; * - * Explanation of the fields of RedisModuleCommandKeySpec: + * Explanation of the fields of RedictModuleCommandKeySpec: * * * `notes`: Optional notes or clarifications about this key spec. * @@ -1764,20 +1764,20 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * `REDISMODULE_CMD_KEY_VARIABLE_FLAGS`: Some keys might have different * flags depending on arguments. * - * - `args`: An array of RedisModuleCommandArg, terminated by an element memset - * to zero. RedisModuleCommandArg is a structure with at the fields described + * - `args`: An array of RedictModuleCommandArg, terminated by an element memset + * to zero. RedictModuleCommandArg is a structure with at the fields described * below. * - * typedef struct RedisModuleCommandArg { + * typedef struct RedictModuleCommandArg { * const char *name; - * RedisModuleCommandArgType type; + * RedictModuleCommandArgType type; * int key_spec_index; * const char *token; * const char *summary; * const char *since; * int flags; - * struct RedisModuleCommandArg *subargs; - * } RedisModuleCommandArg; + * struct RedictModuleCommandArg *subargs; + * } RedictModuleCommandArg; * * Explanation of the fields: * @@ -1806,7 +1806,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * be displayed when creating the command syntax from the output of * `COMMAND`. If `token` is not NULL, it should also be displayed. * - * Explanation of `RedisModuleCommandArgType`: + * Explanation of `RedictModuleCommandArgType`: * * * `REDISMODULE_ARG_TYPE_STRING`: String argument. * * `REDISMODULE_ARG_TYPE_INTEGER`: Integer argument. @@ -1838,7 +1838,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * and `errno` is set to EINVAL if invalid info was provided or EEXIST if info * has already been set. If the info is invalid, a warning is logged explaining * which part of the info is invalid and why. */ -int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo *info) { +int RM_SetCommandInfo(RedictModuleCommand *command, const RedictModuleCommandInfo *info) { if (!moduleValidateCommandInfo(info)) { errno = EINVAL; return REDISMODULE_ERR; @@ -1863,7 +1863,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo if (info->complexity) cmd->complexity = zstrdup(info->complexity); if (info->since) cmd->since = zstrdup(info->since); - const RedisModuleCommandInfoVersion *version = info->version; + const RedictModuleCommandInfoVersion *version = info->version; if (info->history) { size_t count = 0; while (moduleCmdHistoryEntryAt(version, info->history, count)->since) @@ -1871,7 +1871,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo serverAssert(count < SIZE_MAX / sizeof(commandHistory)); cmd->history = zmalloc(sizeof(commandHistory) * (count + 1)); for (size_t j = 0; j < count; j++) { - RedisModuleCommandHistoryEntry *entry = + RedictModuleCommandHistoryEntry *entry = moduleCmdHistoryEntryAt(version, info->history, j); cmd->history[j].since = zstrdup(entry->since); cmd->history[j].changes = zstrdup(entry->changes); @@ -1906,10 +1906,10 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo zfree(cmd->key_specs); cmd->key_specs = zmalloc(sizeof(keySpec) * count); - /* Copy the contents of the RedisModuleCommandKeySpec array. */ + /* Copy the contents of the RedictModuleCommandKeySpec array. */ cmd->key_specs_num = count; for (size_t j = 0; j < count; j++) { - RedisModuleCommandKeySpec *spec = + RedictModuleCommandKeySpec *spec = moduleCmdKeySpecAt(version, info->key_specs, j); cmd->key_specs[j].notes = spec->notes ? zstrdup(spec->notes) : NULL; cmd->key_specs[j].flags = moduleConvertKeySpecsFlags(spec->flags, 1); @@ -1983,8 +1983,8 @@ static inline int isPowerOfTwo(uint64_t v) { } /* Returns 1 if the command info is valid and 0 otherwise. */ -static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { - const RedisModuleCommandInfoVersion *version = info->version; +static int moduleValidateCommandInfo(const RedictModuleCommandInfo *info) { + const RedictModuleCommandInfoVersion *version = info->version; if (!version) { serverLog(LL_WARNING, "Invalid command info: version missing"); return 0; @@ -2012,7 +2012,7 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { moduleCmdKeySpecAt(version, info->key_specs, j)->begin_search_type; j++) { - RedisModuleCommandKeySpec *spec = + RedictModuleCommandKeySpec *spec = moduleCmdKeySpecAt(version, info->key_specs, j); if (j >= INT_MAX) { serverLog(LL_WARNING, "Invalid command info: Too many key specs"); @@ -2103,13 +2103,13 @@ static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api) { return out; } -/* Validates an array of RedisModuleCommandArg. Returns 1 if it's valid and 0 if +/* Validates an array of RedictModuleCommandArg. Returns 1 if it's valid and 0 if * it's invalid. */ -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static int moduleValidateCommandArgs(RedictModuleCommandArg *args, + const RedictModuleCommandInfoVersion *version) { if (args == NULL) return 1; /* Missing args is OK. */ for (size_t j = 0; moduleCmdArgAt(version, args, j)->name != NULL; j++) { - RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); + RedictModuleCommandArg *arg = moduleCmdArgAt(version, args, j); int arg_type_error = 0; moduleConvertArgType(arg->type, &arg_type_error); if (arg_type_error) { @@ -2174,17 +2174,17 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, return 1; } -/* Converts an array of RedisModuleCommandArg into a freshly allocated array of +/* Converts an array of RedictModuleCommandArg into a freshly allocated array of * struct redictCommandArg. */ -static struct redictCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static struct redictCommandArg *moduleCopyCommandArgs(RedictModuleCommandArg *args, + const RedictModuleCommandInfoVersion *version) { size_t count = 0; while (moduleCmdArgAt(version, args, count)->name) count++; serverAssert(count < SIZE_MAX / sizeof(struct redictCommandArg)); struct redictCommandArg *realargs = zcalloc((count+1) * sizeof(redisCommandArg)); for (size_t j = 0; j < count; j++) { - RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); + RedictModuleCommandArg *arg = moduleCmdArgAt(version, args, j); realargs[j].name = zstrdup(arg->name); realargs[j].type = moduleConvertArgType(arg->type, NULL); if (arg->type == REDISMODULE_ARG_TYPE_KEY) @@ -2202,7 +2202,7 @@ static struct redictCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *arg return realargs; } -static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { +static redisCommandArgType moduleConvertArgType(RedictModuleCommandArgType type, int *error) { if (error) *error = 0; switch (type) { case REDISMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; @@ -2228,18 +2228,18 @@ static int moduleConvertArgFlags(int flags) { return realflags; } -/* Return `struct RedisModule *` as `void *` to avoid exposing it outside of module.c. */ +/* Return `struct RedictModule *` as `void *` to avoid exposing it outside of module.c. */ void *moduleGetHandleByName(char *modulename) { return dictFetchValue(modules,modulename); } /* Returns 1 if `cmd` is a command of the module `modulename`. 0 otherwise. */ int moduleIsModuleCommand(void *module_handle, struct redictCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) + if (cmd->proc != RedictModuleCommandDispatcher) return 0; if (module_handle == NULL) return 0; - RedisModuleCommand *cp = cmd->module_cmd; + RedictModuleCommand *cp = cmd->module_cmd; return (cp->module == module_handle); } @@ -2257,12 +2257,12 @@ void moduleListFree(void *config) { zfree(config); } -void RM_SetModuleAttribs(RedisModuleCtx *ctx, const char *name, int ver, int apiver) { +void RM_SetModuleAttribs(RedictModuleCtx *ctx, const char *name, int ver, int apiver) { /* Called by RM_Init() to setup the `ctx->module` structure. * * This is an internal function, Redis modules developers don't need * to use it. */ - RedisModule *module; + RedictModule *module; if (ctx->module != NULL) return; module = zmalloc(sizeof(*module)); @@ -2316,7 +2316,7 @@ ustime_t RM_Microseconds(void) { /* Return the cached UNIX time in microseconds. * It is updated in the server cron job and before executing a command. * It is useful for complex call stacks, such as a command causing a - * key space notification, causing a module to execute a RedisModule_Call, + * key space notification, causing a module to execute a RedictModule_Call, * causing another notification, etc. * It makes sense that all this callbacks would use the same clock. */ ustime_t RM_CachedMicroseconds(void) { @@ -2332,7 +2332,7 @@ ustime_t RM_CachedMicroseconds(void) { * * This function is not thread safe, If used in module thread and blocked callback (possibly main thread) * simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */ -int RM_BlockedClientMeasureTimeStart(RedisModuleBlockedClient *bc) { +int RM_BlockedClientMeasureTimeStart(RedictModuleBlockedClient *bc) { elapsedStart(&(bc->background_timer)); return REDISMODULE_OK; } @@ -2345,7 +2345,7 @@ int RM_BlockedClientMeasureTimeStart(RedisModuleBlockedClient *bc) { * * This function is not thread safe, If used in module thread and blocked callback (possibly main thread) * simultaneously, it's recommended to protect them with lock owned by caller instead of GIL. */ -int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { +int RM_BlockedClientMeasureTimeEnd(RedictModuleBlockedClient *bc) { // If the counter is 0 then we haven't called RM_BlockedClientMeasureTimeStart if (!bc->background_timer) return REDISMODULE_ERR; @@ -2374,7 +2374,7 @@ int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { * loading (in the `rdb_load` callback, in which case it'll reject commands with * the -LOADING error) */ -void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { +void RM_Yield(RedictModuleCtx *ctx, int flags, const char *busy_reply) { static int yield_nesting = 0; /* Avoid nested calls to RM_Yield */ if (yield_nesting) @@ -2450,7 +2450,7 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { * Generally, modules don't need to bother with this, as the process will just * terminate if a read error happens, however, setting this flag would allow * repl-diskless-load to work if enabled. - * The module should use RedisModule_IsIOError after reads, before using the + * The module should use RedictModule_IsIOError after reads, before using the * data that was read, and in case of error, propagate it upwards, and also be * able to release the partially populated value and all it's allocations. * @@ -2467,7 +2467,7 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { * a key-space notification callback. This flag allows to change this behavior * and fire nested key-space notifications. Notice: if enabled, the module * should protected itself from infinite recursion. */ -void RM_SetModuleOptions(RedisModuleCtx *ctx, int options) { +void RM_SetModuleOptions(RedictModuleCtx *ctx, int options) { ctx->module->options = options; } @@ -2478,7 +2478,7 @@ void RM_SetModuleOptions(RedisModuleCtx *ctx, int options) { * the option REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED has been set using * RM_SetModuleOptions(). */ -int RM_SignalModifiedKey(RedisModuleCtx *ctx, RedisModuleString *keyname) { +int RM_SignalModifiedKey(RedictModuleCtx *ctx, RedictModuleString *keyname) { signalModifiedKey(ctx->client,ctx->client->db,keyname); return REDISMODULE_OK; } @@ -2496,18 +2496,18 @@ int RM_SignalModifiedKey(RedisModuleCtx *ctx, RedisModuleString *keyname) { * keys, call replies and Redis string objects once the command returns. In most * cases this eliminates the need of calling the following functions: * - * 1. RedisModule_CloseKey() - * 2. RedisModule_FreeCallReply() - * 3. RedisModule_FreeString() + * 1. RedictModule_CloseKey() + * 2. RedictModule_FreeCallReply() + * 3. RedictModule_FreeString() * * These functions can still be used with automatic memory management enabled, * to optimize loops that make numerous allocations for example. */ -void RM_AutoMemory(RedisModuleCtx *ctx) { +void RM_AutoMemory(RedictModuleCtx *ctx) { ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; } /* Add a new object to release automatically when the callback returns. */ -void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { +void autoMemoryAdd(RedictModuleCtx *ctx, int type, void *ptr) { if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; if (ctx->amqueue_used == ctx->amqueue_len) { ctx->amqueue_len *= 2; @@ -2524,7 +2524,7 @@ void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { * * The function returns 1 if the object was actually found in the auto memory * pool, otherwise 0 is returned. */ -int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { +int autoMemoryFreed(RedictModuleCtx *ctx, int type, void *ptr) { if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return 0; int count = (ctx->amqueue_used+1)/2; @@ -2555,7 +2555,7 @@ int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { } /* Release all the objects in queue. */ -void autoMemoryCollect(RedisModuleCtx *ctx) { +void autoMemoryCollect(RedictModuleCtx *ctx) { if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; /* Clear the AUTO_MEMORY flag from the context, otherwise the functions * we call to free the resources, will try to scan the auto release @@ -2584,7 +2584,7 @@ void autoMemoryCollect(RedisModuleCtx *ctx) { * -------------------------------------------------------------------------- */ /* Create a new module string object. The returned string must be freed - * with RedisModule_FreeString(), unless automatic memory is enabled. + * with RedictModule_FreeString(), unless automatic memory is enabled. * * The string is created by copying the `len` bytes starting * at `ptr`. No reference is retained to the passed buffer. @@ -2593,21 +2593,21 @@ void autoMemoryCollect(RedisModuleCtx *ctx) { * a string out of the context scope. However in that case, the automatic * memory management will not be available, and the string memory must be * managed manually. */ -RedisModuleString *RM_CreateString(RedisModuleCtx *ctx, const char *ptr, size_t len) { - RedisModuleString *o = createStringObject(ptr,len); +RedictModuleString *RM_CreateString(RedictModuleCtx *ctx, const char *ptr, size_t len) { + RedictModuleString *o = createStringObject(ptr,len); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); return o; } /* Create a new module string object from a printf format and arguments. - * The returned string must be freed with RedisModule_FreeString(), unless + * The returned string must be freed with RedictModule_FreeString(), unless * automatic memory is enabled. * * The string is created using the sds formatter function sdscatvprintf(). * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, ...) { + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringPrintf(RedictModuleCtx *ctx, const char *fmt, ...) { sds s = sdsempty(); va_list ap; @@ -2615,89 +2615,89 @@ RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, . s = sdscatvprintf(s, fmt, ap); va_end(ap); - RedisModuleString *o = createObject(OBJ_STRING, s); + RedictModuleString *o = createObject(OBJ_STRING, s); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); return o; } -/* Like RedisModule_CreateString(), but creates a string starting from a `long long` +/* Like RedictModule_CreateString(), but creates a string starting from a `long long` * integer instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromLongLong(RedisModuleCtx *ctx, long long ll) { + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringFromLongLong(RedictModuleCtx *ctx, long long ll) { char buf[LONG_STR_SIZE]; size_t len = ll2string(buf,sizeof(buf),ll); return RM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a `unsigned long long` +/* Like RedictModule_CreateString(), but creates a string starting from a `unsigned long long` * integer instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromULongLong(RedisModuleCtx *ctx, unsigned long long ull) { + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringFromULongLong(RedictModuleCtx *ctx, unsigned long long ull) { char buf[LONG_STR_SIZE]; size_t len = ull2string(buf,sizeof(buf),ull); return RM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a double +/* Like RedictModule_CreateString(), but creates a string starting from a double * instead of taking a buffer and its length. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_CreateStringFromDouble(RedisModuleCtx *ctx, double d) { +RedictModuleString *RM_CreateStringFromDouble(RedictModuleCtx *ctx, double d) { char buf[MAX_D2STRING_CHARS]; size_t len = d2string(buf,sizeof(buf),d); return RM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a long +/* Like RedictModule_CreateString(), but creates a string starting from a long * double. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromLongDouble(RedisModuleCtx *ctx, long double ld, int humanfriendly) { + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringFromLongDouble(RedictModuleCtx *ctx, long double ld, int humanfriendly) { char buf[MAX_LONG_DOUBLE_CHARS]; size_t len = ld2string(buf,sizeof(buf),ld, (humanfriendly ? LD_STR_HUMAN : LD_STR_AUTO)); return RM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from another - * RedisModuleString. +/* Like RedictModule_CreateString(), but creates a string starting from another + * RedictModuleString. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. * * The passed context 'ctx' may be NULL if necessary, see the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromString(RedisModuleCtx *ctx, const RedisModuleString *str) { - RedisModuleString *o = dupStringObject(str); + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringFromString(RedictModuleCtx *ctx, const RedictModuleString *str) { + RedictModuleString *o = dupStringObject(str); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); return o; } /* Creates a string from a stream ID. The returned string must be released with - * RedisModule_FreeString(), unless automatic memory is enabled. + * RedictModule_FreeString(), unless automatic memory is enabled. * * The passed context `ctx` may be NULL if necessary. See the - * RedisModule_CreateString() documentation for more info. */ -RedisModuleString *RM_CreateStringFromStreamID(RedisModuleCtx *ctx, const RedisModuleStreamID *id) { + * RedictModule_CreateString() documentation for more info. */ +RedictModuleString *RM_CreateStringFromStreamID(RedictModuleCtx *ctx, const RedictModuleStreamID *id) { streamID streamid = {id->ms, id->seq}; - RedisModuleString *o = createObjectFromStreamID(&streamid); + RedictModuleString *o = createObjectFromStreamID(&streamid); if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, o); return o; } @@ -2717,16 +2717,16 @@ RedisModuleString *RM_CreateStringFromStreamID(RedisModuleCtx *ctx, const RedisM * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { +void RM_FreeString(RedictModuleCtx *ctx, RedictModuleString *str) { decrRefCount(str); if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str); } /* Every call to this function, will make the string 'str' requiring - * an additional call to RedisModule_FreeString() in order to really + * an additional call to RedictModule_FreeString() in order to really * free the string. Note that the automatic freeing of the string obtained * enabling modules automatic memory management counts for one - * RedisModule_FreeString() call (it is just executed automatically). + * RedictModule_FreeString() call (it is just executed automatically). * * Normally you want to call this function when, at the same time * the following conditions are true: @@ -2748,7 +2748,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { * It is possible to call this function with a NULL context. * * When strings are going to be retained for an extended duration, it is good - * practice to also call RedisModule_TrimStringAllocation() in order to + * practice to also call RedictModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference retained strings from other threads *must* @@ -2757,7 +2757,7 @@ void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str) { * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { +void RM_RetainString(RedictModuleCtx *ctx, RedictModuleString *str) { if (ctx == NULL || !autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str)) { /* Increment the string reference counting only if we can't * just remove the object from the list of objects that should @@ -2767,33 +2767,33 @@ void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { * value? Because this way we ensure that the object refcount * value is 1 (instead of going to 2 to be dropped later to 1) * after the call to this function. This is needed for functions - * like RedisModule_StringAppendBuffer() to work. */ + * like RedictModule_StringAppendBuffer() to work. */ incrRefCount(str); } } /** -* This function can be used instead of RedisModule_RetainString(). +* This function can be used instead of RedictModule_RetainString(). * The main difference between the two is that this function will always -* succeed, whereas RedisModule_RetainString() may fail because of an +* succeed, whereas RedictModule_RetainString() may fail because of an * assertion. * -* The function returns a pointer to RedisModuleString, which is owned -* by the caller. It requires a call to RedisModule_FreeString() to free +* The function returns a pointer to RedictModuleString, which is owned +* by the caller. It requires a call to RedictModule_FreeString() to free * the string when automatic memory management is disabled for the context. * When automatic memory management is enabled, you can either call -* RedisModule_FreeString() or let the automation free it. +* RedictModule_FreeString() or let the automation free it. * -* This function is more efficient than RedisModule_CreateStringFromString() +* This function is more efficient than RedictModule_CreateStringFromString() * because whenever possible, it avoids copying the underlying -* RedisModuleString. The disadvantage of using this function is that it -* might not be possible to use RedisModule_StringAppendBuffer() on the -* returned RedisModuleString. +* RedictModuleString. The disadvantage of using this function is that it +* might not be possible to use RedictModule_StringAppendBuffer() on the +* returned RedictModuleString. * * It is possible to call this function with a NULL context. * * When strings are going to be held for an extended duration, it is good - * practice to also call RedisModule_TrimStringAllocation() in order to + * practice to also call RedictModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference held strings from other threads *must* @@ -2802,7 +2802,7 @@ void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { * * This API is not thread safe, access to these retained strings (if they originated * from a client command arguments) must be done with GIL locked. */ -RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { +RedictModuleString* RM_HoldString(RedictModuleCtx *ctx, RedictModuleString *str) { if (str->refcount == OBJ_STATIC_REFCOUNT) { return RM_CreateStringFromString(ctx, str); } @@ -2833,7 +2833,7 @@ RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { * So it's safer to just increase the ref count * and add the String to auto memory again. * - * The limitation is that it is not possible to use RedisModule_StringAppendBuffer + * The limitation is that it is not possible to use RedictModule_StringAppendBuffer * on the String. */ autoMemoryAdd(ctx,REDISMODULE_AM_STRING,str); @@ -2844,7 +2844,7 @@ RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { /* Given a string module object, this function returns the string pointer * and length of the string. The returned pointer and length should only * be used for read only accesses and never modified. */ -const char *RM_StringPtrLen(const RedisModuleString *str, size_t *len) { +const char *RM_StringPtrLen(const RedictModuleString *str, size_t *len) { if (str == NULL) { const char *errmsg = "(NULL string reply referenced in module)"; if (len) *len = strlen(errmsg); @@ -2862,7 +2862,7 @@ const char *RM_StringPtrLen(const RedisModuleString *str, size_t *len) { * Returns REDISMODULE_OK on success. If the string can't be parsed * as a valid, strict `long long` (no spaces before/after), REDISMODULE_ERR * is returned. */ -int RM_StringToLongLong(const RedisModuleString *str, long long *ll) { +int RM_StringToLongLong(const RedictModuleString *str, long long *ll) { return string2ll(str->ptr,sdslen(str->ptr),ll) ? REDISMODULE_OK : REDISMODULE_ERR; } @@ -2871,14 +2871,14 @@ int RM_StringToLongLong(const RedisModuleString *str, long long *ll) { * Returns REDISMODULE_OK on success. If the string can't be parsed * as a valid, strict `unsigned long long` (no spaces before/after), REDISMODULE_ERR * is returned. */ -int RM_StringToULongLong(const RedisModuleString *str, unsigned long long *ull) { +int RM_StringToULongLong(const RedictModuleString *str, unsigned long long *ull) { return string2ull(str->ptr,ull) ? REDISMODULE_OK : REDISMODULE_ERR; } /* Convert the string into a double, storing it at `*d`. * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToDouble(const RedisModuleString *str, double *d) { +int RM_StringToDouble(const RedictModuleString *str, double *d) { int retval = getDoubleFromObject(str,d); return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; } @@ -2886,7 +2886,7 @@ int RM_StringToDouble(const RedisModuleString *str, double *d) { /* Convert the string into a long double, storing it at `*ld`. * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToLongDouble(const RedisModuleString *str, long double *ld) { +int RM_StringToLongDouble(const RedictModuleString *str, long double *ld) { int retval = string2ld(str->ptr,sdslen(str->ptr),ld); return retval ? REDISMODULE_OK : REDISMODULE_ERR; } @@ -2896,7 +2896,7 @@ int RM_StringToLongDouble(const RedisModuleString *str, long double *ld) { * is not a valid string representation of a stream ID. The special IDs "+" and * "-" are allowed. */ -int RM_StringToStreamID(const RedisModuleString *str, RedisModuleStreamID *id) { +int RM_StringToStreamID(const RedictModuleString *str, RedictModuleStreamID *id) { streamID streamid; if (streamParseID(str, &streamid) == C_OK) { id->ms = streamid.ms; @@ -2910,13 +2910,13 @@ int RM_StringToStreamID(const RedisModuleString *str, RedisModuleStreamID *id) { /* Compare two string objects, returning -1, 0 or 1 respectively if * a < b, a == b, a > b. Strings are compared byte by byte as two * binary blobs without any encoding care / collation attempt. */ -int RM_StringCompare(const RedisModuleString *a, const RedisModuleString *b) { +int RM_StringCompare(const RedictModuleString *a, const RedictModuleString *b) { return compareStringObjects(a,b); } /* Return the (possibly modified in encoding) input 'str' object if * the string is unshared, otherwise NULL is returned. */ -RedisModuleString *moduleAssertUnsharedString(RedisModuleString *str) { +RedictModuleString *moduleAssertUnsharedString(RedictModuleString *str) { if (str->refcount != 1) { serverLog(LL_WARNING, "Module attempted to use an in-place string modify operation " @@ -2940,7 +2940,7 @@ RedisModuleString *moduleAssertUnsharedString(RedisModuleString *str) { /* Append the specified buffer to the string 'str'. The string must be a * string created by the user that is referenced only a single time, otherwise * REDISMODULE_ERR is returned and the operation is not performed. */ -int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len) { +int RM_StringAppendBuffer(RedictModuleCtx *ctx, RedictModuleString *str, const char *buf, size_t len) { UNUSED(ctx); str = moduleAssertUnsharedString(str); if (str == NULL) return REDISMODULE_ERR; @@ -2948,9 +2948,9 @@ int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const cha return REDISMODULE_OK; } -/* Trim possible excess memory allocated for a RedisModuleString. +/* Trim possible excess memory allocated for a RedictModuleString. * - * Sometimes a RedisModuleString may have more memory allocated for + * Sometimes a RedictModuleString may have more memory allocated for * it than required, typically for argv arguments that were constructed * from network buffers. This function optimizes such strings by reallocating * their memory, which is useful for strings that are not short lived but @@ -2971,7 +2971,7 @@ int RM_StringAppendBuffer(RedisModuleCtx *ctx, RedisModuleString *str, const cha * in a race condition with the auto-trim, which could result with * data corruption. */ -void RM_TrimStringAllocation(RedisModuleString *str) { +void RM_TrimStringAllocation(RedictModuleString *str) { if (!str) return; trimStringObjectIfNeeded(str, 1); } @@ -2985,7 +2985,7 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * 'return' in order to return from the command implementation with: * * if (... some condition ...) - * return RedisModule_ReplyWithLongLong(ctx,mycount); + * return RedictModule_ReplyWithLongLong(ctx,mycount); * * ### Reply with collection functions * @@ -3005,9 +3005,9 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * * Example: * - * if (argc != 3) return RedisModule_WrongArity(ctx); + * if (argc != 3) return RedictModule_WrongArity(ctx); */ -int RM_WrongArity(RedisModuleCtx *ctx) { +int RM_WrongArity(RedictModuleCtx *ctx) { addReplyErrorArity(ctx->client); return REDISMODULE_OK; } @@ -3026,7 +3026,7 @@ int RM_WrongArity(RedisModuleCtx *ctx) { * context of a thread safe context that was not initialized with a blocked * client object. Other contexts without associated clients are the ones * initialized to run the timers callbacks. */ -client *moduleGetReplyClient(RedisModuleCtx *ctx) { +client *moduleGetReplyClient(RedictModuleCtx *ctx) { if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) { if (ctx->blocked_client) return ctx->blocked_client->reply_client; @@ -3043,7 +3043,7 @@ client *moduleGetReplyClient(RedisModuleCtx *ctx) { /* Send an integer reply to the client, with the specified `long long` value. * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) { +int RM_ReplyWithLongLong(RedictModuleCtx *ctx, long long ll) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyLongLong(c,ll); @@ -3056,15 +3056,15 @@ int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) { * the initial error code. The function only provides the initial "-", so * the usage is, for example: * - * RedisModule_ReplyWithError(ctx,"ERR Wrong Type"); + * RedictModule_ReplyWithError(ctx,"ERR Wrong Type"); * * and not just: * - * RedisModule_ReplyWithError(ctx,"Wrong Type"); + * RedictModule_ReplyWithError(ctx,"Wrong Type"); * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) { +int RM_ReplyWithError(RedictModuleCtx *ctx, const char *err) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyErrorFormat(c,"-%s",err); @@ -3077,15 +3077,15 @@ int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) { * the initial error code. The function only provides the initial "-", so * the usage is, for example: * - * RedisModule_ReplyWithErrorFormat(ctx,"ERR Wrong Type: %s",type); + * RedictModule_ReplyWithErrorFormat(ctx,"ERR Wrong Type: %s",type); * * and not just: * - * RedisModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); + * RedictModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { +int RM_ReplyWithErrorFormat(RedictModuleCtx *ctx, const char *fmt, ...) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; @@ -3108,7 +3108,7 @@ int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { * overhead, like "OK" or similar replies. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) { +int RM_ReplyWithSimpleString(RedictModuleCtx *ctx, const char *msg) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyProto(c,"+",1); @@ -3122,7 +3122,7 @@ int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) { #define COLLECTION_REPLY_SET 3 #define COLLECTION_REPLY_ATTRIBUTE 4 -int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { +int moduleReplyWithCollection(RedictModuleCtx *ctx, long len, int type) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; if (len == REDISMODULE_POSTPONED_LEN) { @@ -3177,7 +3177,7 @@ int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { * Use RM_ReplySetArrayLength() to set deferred length. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { +int RM_ReplyWithArray(RedictModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ARRAY); } @@ -3194,7 +3194,7 @@ int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { * Use RM_ReplySetMapLength() to set deferred length. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { +int RM_ReplyWithMap(RedictModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_MAP); } @@ -3211,7 +3211,7 @@ int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { * Use RM_ReplySetSetLength() to set deferred length. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { +int RM_ReplyWithSet(RedictModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_SET); } @@ -3227,7 +3227,7 @@ int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { * * Not supported by RESP2 and will return REDISMODULE_ERR, otherwise * the function always returns REDISMODULE_OK. */ -int RM_ReplyWithAttribute(RedisModuleCtx *ctx, long len) { +int RM_ReplyWithAttribute(RedictModuleCtx *ctx, long len) { if (ctx->client->resp == 2) return REDISMODULE_ERR; return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ATTRIBUTE); @@ -3238,10 +3238,10 @@ int RM_ReplyWithAttribute(RedisModuleCtx *ctx, long len) { * * Note: In RESP3 there's no difference between Null reply and * NullArray reply, so to prevent ambiguity it's better to avoid - * using this API and use RedisModule_ReplyWithNull instead. + * using this API and use RedictModule_ReplyWithNull instead. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNullArray(RedisModuleCtx *ctx) { +int RM_ReplyWithNullArray(RedictModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyNullArray(c); @@ -3251,21 +3251,21 @@ int RM_ReplyWithNullArray(RedisModuleCtx *ctx) { /* Reply to the client with an empty array. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyArray(RedisModuleCtx *ctx) { +int RM_ReplyWithEmptyArray(RedictModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReply(c,shared.emptyarray); return REDISMODULE_OK; } -void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { +void moduleReplySetCollectionLength(RedictModuleCtx *ctx, long len, int type) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return; if (ctx->postponed_arrays_count == 0) { serverLog(LL_WARNING, "API misuse detected in module %s: " - "RedisModule_ReplySet*Length() called without previous " - "RedisModule_ReplyWith*(ctx,REDISMODULE_POSTPONED_LEN) " + "RedictModule_ReplySet*Length() called without previous " + "RedictModule_ReplyWith*(ctx,REDISMODULE_POSTPONED_LEN) " "call.", ctx->module->name); return; } @@ -3292,7 +3292,7 @@ void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { } } -/* When RedisModule_ReplyWithArray() is used with the argument +/* When RedictModule_ReplyWithArray() is used with the argument * REDISMODULE_POSTPONED_LEN, because we don't know beforehand the number * of items we are going to output as elements of the array, this function * will take care to set the array length. @@ -3304,43 +3304,43 @@ void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { * For example in order to output an array like [1,[10,20,30]] we * could write: * - * RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - * RedisModule_ReplyWithLongLong(ctx,1); - * RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - * RedisModule_ReplyWithLongLong(ctx,10); - * RedisModule_ReplyWithLongLong(ctx,20); - * RedisModule_ReplyWithLongLong(ctx,30); - * RedisModule_ReplySetArrayLength(ctx,3); // Set len of 10,20,30 array. - * RedisModule_ReplySetArrayLength(ctx,2); // Set len of top array + * RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + * RedictModule_ReplyWithLongLong(ctx,1); + * RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + * RedictModule_ReplyWithLongLong(ctx,10); + * RedictModule_ReplyWithLongLong(ctx,20); + * RedictModule_ReplyWithLongLong(ctx,30); + * RedictModule_ReplySetArrayLength(ctx,3); // Set len of 10,20,30 array. + * RedictModule_ReplySetArrayLength(ctx,2); // Set len of top array * * Note that in the above example there is no reason to postpone the array * length, since we produce a fixed number of elements, but in the practice * the code may use an iterator or other ways of creating the output so * that is not easy to calculate in advance the number of elements. */ -void RM_ReplySetArrayLength(RedisModuleCtx *ctx, long len) { +void RM_ReplySetArrayLength(RedictModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ARRAY); } -/* Very similar to RedisModule_ReplySetArrayLength except `len` should +/* Very similar to RedictModule_ReplySetArrayLength except `len` should * exactly half of the number of `ReplyWith*` functions called in the * context of the map. * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ -void RM_ReplySetMapLength(RedisModuleCtx *ctx, long len) { +void RM_ReplySetMapLength(RedictModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_MAP); } -/* Very similar to RedisModule_ReplySetArrayLength +/* Very similar to RedictModule_ReplySetArrayLength * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ -void RM_ReplySetSetLength(RedisModuleCtx *ctx, long len) { +void RM_ReplySetSetLength(RedictModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_SET); } -/* Very similar to RedisModule_ReplySetMapLength +/* Very similar to RedictModule_ReplySetMapLength * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. * * Must not be called if RM_ReplyWithAttribute returned an error. */ -void RM_ReplySetAttributeLength(RedisModuleCtx *ctx, long len) { +void RM_ReplySetAttributeLength(RedictModuleCtx *ctx, long len) { if (ctx->client->resp == 2) return; moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ATTRIBUTE); } @@ -3348,7 +3348,7 @@ void RM_ReplySetAttributeLength(RedisModuleCtx *ctx, long len) { /* Reply with a bulk string, taking in input a C buffer pointer and length. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithStringBuffer(RedisModuleCtx *ctx, const char *buf, size_t len) { +int RM_ReplyWithStringBuffer(RedictModuleCtx *ctx, const char *buf, size_t len) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyBulkCBuffer(c,(char*)buf,len); @@ -3359,17 +3359,17 @@ int RM_ReplyWithStringBuffer(RedisModuleCtx *ctx, const char *buf, size_t len) { * assumed to be null-terminated. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithCString(RedisModuleCtx *ctx, const char *buf) { +int RM_ReplyWithCString(RedictModuleCtx *ctx, const char *buf) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyBulkCString(c,(char*)buf); return REDISMODULE_OK; } -/* Reply with a bulk string, taking in input a RedisModuleString object. +/* Reply with a bulk string, taking in input a RedictModuleString object. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithString(RedisModuleCtx *ctx, RedisModuleString *str) { +int RM_ReplyWithString(RedictModuleCtx *ctx, RedictModuleString *str) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyBulk(c,str); @@ -3379,7 +3379,7 @@ int RM_ReplyWithString(RedisModuleCtx *ctx, RedisModuleString *str) { /* Reply with an empty string. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyString(RedisModuleCtx *ctx) { +int RM_ReplyWithEmptyString(RedictModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReply(c,shared.emptybulk); @@ -3390,7 +3390,7 @@ int RM_ReplyWithEmptyString(RedisModuleCtx *ctx) { * taking in input a C buffer pointer, length and a 3 character type/extension. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithVerbatimStringType(RedisModuleCtx *ctx, const char *buf, size_t len, const char *ext) { +int RM_ReplyWithVerbatimStringType(RedictModuleCtx *ctx, const char *buf, size_t len, const char *ext) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyVerbatim(c, buf, len, ext); @@ -3401,14 +3401,14 @@ int RM_ReplyWithVerbatimStringType(RedisModuleCtx *ctx, const char *buf, size_t * taking in input a C buffer pointer and length. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithVerbatimString(RedisModuleCtx *ctx, const char *buf, size_t len) { +int RM_ReplyWithVerbatimString(RedictModuleCtx *ctx, const char *buf, size_t len) { return RM_ReplyWithVerbatimStringType(ctx, buf, len, "txt"); } /* Reply to the client with a NULL. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNull(RedisModuleCtx *ctx) { +int RM_ReplyWithNull(RedictModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyNull(c); @@ -3422,15 +3422,15 @@ int RM_ReplyWithNull(RedisModuleCtx *ctx) { * In RESP2, it's a string response of "1" and "0" for true and false respectively. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithBool(RedisModuleCtx *ctx, int b) { +int RM_ReplyWithBool(RedictModuleCtx *ctx, int b) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyBool(c,b); return REDISMODULE_OK; } -/* Reply exactly what a Redis command returned us with RedisModule_Call(). - * This function is useful when we use RedisModule_Call() in order to +/* Reply exactly what a Redis command returned us with RedictModule_Call(). + * This function is useful when we use RedictModule_Call() in order to * execute some command, as we want to reply to the client exactly the * same reply we obtained by the command. * @@ -3440,9 +3440,9 @@ int RM_ReplyWithBool(RedisModuleCtx *ctx, int b) { * In case of an error, it's the module writer responsibility to translate the reply * to RESP2 (or handle it differently by returning an error). Notice that for * module writer convenience, it is possible to pass `0` as a parameter to the fmt - * argument of `RM_Call` so that the RedisModuleCallReply will return in the same + * argument of `RM_Call` so that the RedictModuleCallReply will return in the same * protocol (RESP2 or RESP3) as set in the current client's context. */ -int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { +int RM_ReplyWithCallReply(RedictModuleCtx *ctx, RedictModuleCallReply *reply) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; if (c->resp == 2 && callReplyIsResp3(reply)) { @@ -3471,13 +3471,13 @@ int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { * Send a string reply obtained converting the double 'd' into a bulk string. * This function is basically equivalent to converting a double into * a string into a C buffer, and then calling the function - * RedisModule_ReplyWithStringBuffer() with the buffer and length. + * RedictModule_ReplyWithStringBuffer() with the buffer and length. * * In RESP3 the string is tagged as a double, while in RESP2 it's just a plain string * that the user will have to parse. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) { +int RM_ReplyWithDouble(RedictModuleCtx *ctx, double d) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyDouble(c,d); @@ -3492,7 +3492,7 @@ int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) { * In RESP2, this is just a plain bulk string response. * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithBigNumber(RedisModuleCtx *ctx, const char *bignum, size_t len) { +int RM_ReplyWithBigNumber(RedictModuleCtx *ctx, const char *bignum, size_t len) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyBigNum(c, bignum, len); @@ -3502,12 +3502,12 @@ int RM_ReplyWithBigNumber(RedisModuleCtx *ctx, const char *bignum, size_t len) { /* Send a string reply obtained converting the long double 'ld' into a bulk * string. This function is basically equivalent to converting a long double * into a string into a C buffer, and then calling the function - * RedisModule_ReplyWithStringBuffer() with the buffer and length. + * RedictModule_ReplyWithStringBuffer() with the buffer and length. * The double string uses human readable formatting (see * `addReplyHumanLongDouble` in networking.c). * * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { +int RM_ReplyWithLongDouble(RedictModuleCtx *ctx, long double ld) { client *c = moduleGetReplyClient(ctx); if (c == NULL) return REDISMODULE_OK; addReplyHumanLongDouble(c, ld); @@ -3523,17 +3523,17 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * * The replicated commands are always wrapped into the MULTI/EXEC that * contains all the commands replicated in a given module command - * execution. However the commands replicated with RedisModule_Call() - * are the first items, the ones replicated with RedisModule_Replicate() + * execution. However the commands replicated with RedictModule_Call() + * are the first items, the ones replicated with RedictModule_Replicate() * will all follow before the EXEC. * * Modules should try to use one interface or the other. * - * This command follows exactly the same interface of RedisModule_Call(), + * This command follows exactly the same interface of RedictModule_Call(), * so a set of format specifiers must be passed, followed by arguments * matching the provided format specifiers. * - * Please refer to RedisModule_Call() for more information. + * Please refer to RedictModule_Call() for more information. * * Using the special "A" and "R" modifiers, the caller can exclude either * the AOF or the replicas from the propagation of the specified command. @@ -3555,7 +3555,7 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * * The command returns REDISMODULE_ERR if the format specifiers are invalid * or the command name does not belong to a known command. */ -int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { +int RM_Replicate(RedictModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { struct redictCommand *cmd; robj **argv = NULL; int argc = 0, flags = 0, j; @@ -3597,7 +3597,7 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) * new state starting from the old one. * * The function always returns REDISMODULE_OK. */ -int RM_ReplicateVerbatim(RedisModuleCtx *ctx) { +int RM_ReplicateVerbatim(RedictModuleCtx *ctx) { alsoPropagate(ctx->client->db->id, ctx->client->argv,ctx->client->argc, PROPAGATE_AOF|PROPAGATE_REPL); @@ -3624,11 +3624,11 @@ int RM_ReplicateVerbatim(RedisModuleCtx *ctx) { * After obtaining the ID, it is possible to check if the command execution * is actually happening in the context of AOF loading, using this macro: * - * if (RedisModule_IsAOFClient(RedisModule_GetClientId(ctx)) { + * if (RedictModule_IsAOFClient(RedictModule_GetClientId(ctx)) { * // Handle it differently. * } */ -unsigned long long RM_GetClientId(RedisModuleCtx *ctx) { +unsigned long long RM_GetClientId(RedictModuleCtx *ctx) { if (ctx->client == NULL) return 0; return ctx->client->id; } @@ -3637,7 +3637,7 @@ unsigned long long RM_GetClientId(RedisModuleCtx *ctx) { * Client ID can be obtained with RM_GetClientId() API. If the client does not * exist, NULL is returned and errno is set to ENOENT. If the client isn't * using an ACL user, NULL is returned and errno is set to ENOTSUP */ -RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { +RedictModuleString *RM_GetClientUserNameById(RedictModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; @@ -3664,7 +3664,7 @@ RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { int modulePopulateClientInfoStructure(void *ci, client *client, int structver) { if (structver != 1) return REDISMODULE_ERR; - RedisModuleClientInfoV1 *ci1 = ci; + RedictModuleClientInfoV1 *ci1 = ci; memset(ci1,0,sizeof(*ci1)); ci1->version = structver; if (client->flags & CLIENT_MULTI) @@ -3696,7 +3696,7 @@ int modulePopulateClientInfoStructure(void *ci, client *client, int structver) { int modulePopulateReplicationInfoStructure(void *ri, int structver) { if (structver != 1) return REDISMODULE_ERR; - RedisModuleReplicationInfoV1 *ri1 = ri; + RedictModuleReplicationInfoV1 *ri1 = ri; memset(ri1,0,sizeof(*ri1)); ri1->version = structver; ri1->master = server.masterhost==NULL; @@ -3710,12 +3710,12 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { } /* Return information about the client with the specified ID (that was - * previously obtained via the RedisModule_GetClientId() API). If the + * previously obtained via the RedictModule_GetClientId() API). If the * client exists, REDISMODULE_OK is returned, otherwise REDISMODULE_ERR * is returned. * * When the client exist and the `ci` pointer is not NULL, but points to - * a structure of type RedisModuleClientInfoV1, previously initialized with + * a structure of type RedictModuleClientInfoV1, previously initialized with * the correct REDISMODULE_CLIENTINFO_INITIALIZER_V1, the structure is populated * with the following fields: * @@ -3745,8 +3745,8 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { * This is the correct usage when we want the client info structure * returned: * - * RedisModuleClientInfo ci = REDISMODULE_CLIENTINFO_INITIALIZER; - * int retval = RedisModule_GetClientInfoById(&ci,client_id); + * RedictModuleClientInfo ci = REDISMODULE_CLIENTINFO_INITIALIZER; + * int retval = RedictModule_GetClientInfoById(&ci,client_id); * if (retval == REDISMODULE_OK) { * printf("Address: %s\n", ci.addr); * } @@ -3765,7 +3765,7 @@ int RM_GetClientInfoById(void *ci, uint64_t id) { * * If the client ID does not exist or if the client has no name associated with * it, NULL is returned. */ -RedisModuleString *RM_GetClientNameById(RedisModuleCtx *ctx, uint64_t id) { +RedictModuleString *RM_GetClientNameById(RedictModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL || client->name == NULL) return NULL; robj *name = client->name; @@ -3782,7 +3782,7 @@ RedisModuleString *RM_GetClientNameById(RedisModuleCtx *ctx, uint64_t id) { * * - ENOENT if the client does not exist * - EINVAL if the name contains invalid characters */ -int RM_SetClientNameById(uint64_t id, RedisModuleString *name) { +int RM_SetClientNameById(uint64_t id, RedictModuleString *name) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; @@ -3796,19 +3796,19 @@ int RM_SetClientNameById(uint64_t id, RedisModuleString *name) { } /* Publish a message to subscribers (see PUBLISH command). */ -int RM_PublishMessage(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) { +int RM_PublishMessage(RedictModuleCtx *ctx, RedictModuleString *channel, RedictModuleString *message) { UNUSED(ctx); return pubsubPublishMessageAndPropagateToCluster(channel, message, 0); } /* Publish a message to shard-subscribers (see SPUBLISH command). */ -int RM_PublishMessageShard(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) { +int RM_PublishMessageShard(RedictModuleCtx *ctx, RedictModuleString *channel, RedictModuleString *message) { UNUSED(ctx); return pubsubPublishMessageAndPropagateToCluster(channel, message, 1); } /* Return the currently selected DB. */ -int RM_GetSelectedDb(RedisModuleCtx *ctx) { +int RM_GetSelectedDb(RedictModuleCtx *ctx) { return ctx->client->db->id; } @@ -3882,7 +3882,7 @@ int RM_GetSelectedDb(RedisModuleCtx *ctx) { * * * REDISMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting */ -int RM_GetContextFlags(RedisModuleCtx *ctx) { +int RM_GetContextFlags(RedictModuleCtx *ctx) { int flags = 0; /* Client specific flags */ @@ -3980,8 +3980,8 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { * replication offset, match the one of the master. When this happens, it is * safe to failover the master without data loss. * - * However modules may generate traffic by calling RedisModule_Call() with - * the "!" flag, or by calling RedisModule_Replicate(), in a context outside + * However modules may generate traffic by calling RedictModule_Call() with + * the "!" flag, or by calling RedictModule_Replicate(), in a context outside * commands execution, for instance in timeout callbacks, threads safe * contexts, and so forth. When modules will generate too much traffic, it * will be hard for the master and replicas offset to match, because there @@ -4005,9 +4005,9 @@ int RM_AvoidReplicaTraffic(void) { * returns. * * If the module command wishes to change something in a different DB and - * returns back to the original one, it should call RedisModule_GetSelectedDb() + * returns back to the original one, it should call RedictModule_GetSelectedDb() * before in order to restore the old DB number before returning. */ -int RM_SelectDb(RedisModuleCtx *ctx, int newid) { +int RM_SelectDb(RedictModuleCtx *ctx, int newid) { int retval = selectDb(ctx->client,newid); return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; } @@ -4018,13 +4018,13 @@ int RM_SelectDb(RedisModuleCtx *ctx, int newid) { * REDISMODULE_OPEN_KEY_NOTOUCH, then checking if NULL was returned and, if not, * calling RM_CloseKey on the opened key. */ -int RM_KeyExists(RedisModuleCtx *ctx, robj *keyname) { +int RM_KeyExists(RedictModuleCtx *ctx, robj *keyname) { robj *value = lookupKeyReadWithFlags(ctx->client->db, keyname, LOOKUP_NOTOUCH); return (value != NULL); } -/* Initialize a RedisModuleKey struct */ -static void moduleInitKey(RedisModuleKey *kp, RedisModuleCtx *ctx, robj *keyname, robj *value, int mode){ +/* Initialize a RedictModuleKey struct */ +static void moduleInitKey(RedictModuleKey *kp, RedictModuleCtx *ctx, robj *keyname, robj *value, int mode){ kp->ctx = ctx; kp->db = ctx->client->db; kp->key = keyname; @@ -4036,7 +4036,7 @@ static void moduleInitKey(RedisModuleKey *kp, RedisModuleCtx *ctx, robj *keyname } /* Initialize the type-specific part of the key. Only when key has a value. */ -static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { +static void moduleInitKeyTypeSpecific(RedictModuleKey *key) { switch (key->value->type) { case OBJ_ZSET: zsetKeyReset(key); break; case OBJ_STREAM: key->u.stream.signalready = 0; break; @@ -4055,7 +4055,7 @@ static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { * a yet not existing key (that will be created, for example, after * a list push operation). If the mode is just REDISMODULE_READ instead, and the * key does not exist, NULL is returned. However it is still safe to - * call RedisModule_CloseKey() and RedisModule_KeyType() on a NULL + * call RedictModule_CloseKey() and RedictModule_KeyType() on a NULL * value. * * Extra flags that can be pass to the API under the mode argument: @@ -4064,8 +4064,8 @@ static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { * * REDISMODULE_OPEN_KEY_NOSTATS - Don't update keyspace hits/misses counters. * * REDISMODULE_OPEN_KEY_NOEXPIRE - Avoid deleting lazy expired keys. * * REDISMODULE_OPEN_KEY_NOEFFECTS - Avoid any effects from fetching the key. */ -RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { - RedisModuleKey *kp; +RedictModuleKey *RM_OpenKey(RedictModuleCtx *ctx, robj *keyname, int mode) { + RedictModuleKey *kp; robj *value; int flags = 0; flags |= (mode & REDISMODULE_OPEN_KEY_NOTOUCH? LOOKUP_NOTOUCH: 0); @@ -4107,8 +4107,8 @@ int RM_GetOpenKeyModesAll(void) { return _REDISMODULE_OPEN_KEY_ALL; } -/* Destroy a RedisModuleKey struct (freeing is the responsibility of the caller). */ -static void moduleCloseKey(RedisModuleKey *key) { +/* Destroy a RedictModuleKey struct (freeing is the responsibility of the caller). */ +static void moduleCloseKey(RedictModuleKey *key) { int signal = SHOULD_SIGNAL_MODIFIED_KEYS(key->ctx); if ((key->mode & REDISMODULE_WRITE) && signal) signalModifiedKey(key->ctx->client,key->db,key->key); @@ -4130,7 +4130,7 @@ static void moduleCloseKey(RedisModuleKey *key) { } /* Close a key handle. */ -void RM_CloseKey(RedisModuleKey *key) { +void RM_CloseKey(RedictModuleKey *key) { if (key == NULL) return; moduleCloseKey(key); autoMemoryFreed(key->ctx,REDISMODULE_AM_KEY,key); @@ -4139,7 +4139,7 @@ void RM_CloseKey(RedisModuleKey *key) { /* Return the type of the key. If the key pointer is NULL then * REDISMODULE_KEYTYPE_EMPTY is returned. */ -int RM_KeyType(RedisModuleKey *key) { +int RM_KeyType(RedictModuleKey *key) { if (key == NULL || key->value == NULL) return REDISMODULE_KEYTYPE_EMPTY; /* We map between defines so that we are free to change the internal * defines as desired. */ @@ -4160,7 +4160,7 @@ int RM_KeyType(RedisModuleKey *key) { * is the number of elements (just counting keys for hashes). * * If the key pointer is NULL or the key is empty, zero is returned. */ -size_t RM_ValueLength(RedisModuleKey *key) { +size_t RM_ValueLength(RedictModuleKey *key) { if (key == NULL || key->value == NULL) return 0; switch(key->value->type) { case OBJ_STRING: return stringObjectLen(key->value); @@ -4177,7 +4177,7 @@ size_t RM_ValueLength(RedisModuleKey *key) { * accept new writes as an empty key (that will be created on demand). * On success REDISMODULE_OK is returned. If the key is not open for * writing REDISMODULE_ERR is returned. */ -int RM_DeleteKey(RedisModuleKey *key) { +int RM_DeleteKey(RedictModuleKey *key) { if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value) { dbDelete(key->db,key->key); @@ -4191,7 +4191,7 @@ int RM_DeleteKey(RedisModuleKey *key) { * accept new writes as an empty key (that will be created on demand). * On success REDISMODULE_OK is returned. If the key is not open for * writing REDISMODULE_ERR is returned. */ -int RM_UnlinkKey(RedisModuleKey *key) { +int RM_UnlinkKey(RedictModuleKey *key) { if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value) { dbAsyncDelete(key->db,key->key); @@ -4203,7 +4203,7 @@ int RM_UnlinkKey(RedisModuleKey *key) { /* Return the key expire value, as milliseconds of remaining TTL. * If no TTL is associated with the key or if the key is empty, * REDISMODULE_NO_EXPIRE is returned. */ -mstime_t RM_GetExpire(RedisModuleKey *key) { +mstime_t RM_GetExpire(RedictModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) return REDISMODULE_NO_EXPIRE; @@ -4220,7 +4220,7 @@ mstime_t RM_GetExpire(RedisModuleKey *key) { * * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetExpire(RedisModuleKey *key, mstime_t expire) { +int RM_SetExpire(RedictModuleKey *key, mstime_t expire) { if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE)) return REDISMODULE_ERR; if (expire != REDISMODULE_NO_EXPIRE) { @@ -4235,7 +4235,7 @@ int RM_SetExpire(RedisModuleKey *key, mstime_t expire) { /* Return the key expire value, as absolute Unix timestamp. * If no TTL is associated with the key or if the key is empty, * REDISMODULE_NO_EXPIRE is returned. */ -mstime_t RM_GetAbsExpire(RedisModuleKey *key) { +mstime_t RM_GetAbsExpire(RedictModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) return REDISMODULE_NO_EXPIRE; @@ -4251,7 +4251,7 @@ mstime_t RM_GetAbsExpire(RedisModuleKey *key) { * * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetAbsExpire(RedisModuleKey *key, mstime_t expire) { +int RM_SetAbsExpire(RedictModuleKey *key, mstime_t expire) { if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != REDISMODULE_NO_EXPIRE)) return REDISMODULE_ERR; if (expire != REDISMODULE_NO_EXPIRE) { @@ -4273,34 +4273,34 @@ void RM_ResetDataset(int restart_aof, int async) { } /* Returns the number of keys in the current db. */ -unsigned long long RM_DbSize(RedisModuleCtx *ctx) { +unsigned long long RM_DbSize(RedictModuleCtx *ctx) { return dbSize(ctx->client->db); } /* Returns a name of a random key, or NULL if current db is empty. */ -RedisModuleString *RM_RandomKey(RedisModuleCtx *ctx) { +RedictModuleString *RM_RandomKey(RedictModuleCtx *ctx) { robj *key = dbRandomKey(ctx->client->db); autoMemoryAdd(ctx,REDISMODULE_AM_STRING,key); return key; } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const RedictModuleString *RM_GetKeyNameFromOptCtx(RedictModuleKeyOptCtx *ctx) { return ctx->from_key; } /* Returns the name of the target key currently being processed. */ -const RedisModuleString *RM_GetToKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const RedictModuleString *RM_GetToKeyNameFromOptCtx(RedictModuleKeyOptCtx *ctx) { return ctx->to_key; } /* Returns the dbid currently being processed. */ -int RM_GetDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int RM_GetDbIdFromOptCtx(RedictModuleKeyOptCtx *ctx) { return ctx->from_dbid; } /* Returns the target dbid currently being processed. */ -int RM_GetToDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int RM_GetToDbIdFromOptCtx(RedictModuleKeyOptCtx *ctx) { return ctx->to_dbid; } /* -------------------------------------------------------------------------- @@ -4313,7 +4313,7 @@ int RM_GetToDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { * value of the key, deleting the old value if any. * On success REDISMODULE_OK is returned. If the key is not open for * writing or there is an active iterator, REDISMODULE_ERR is returned. */ -int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { +int RM_StringSet(RedictModuleKey *key, RedictModuleString *str) { if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; RM_DeleteKey(key); setKey(key->ctx->client,key->db,key->key,str,SETKEY_NO_SIGNAL); @@ -4350,7 +4350,7 @@ int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { * so a RM_StringTruncate() call should be used if there is to enlarge * the string, and later call StringDMA() again to get the pointer. */ -char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { +char *RM_StringDMA(RedictModuleKey *key, size_t *len, int mode) { /* We need to return *some* pointer for empty keys, we just return * a string literal pointer, that is the advantage to be mapped into * a read only memory page, so the module will segfault if a write @@ -4384,7 +4384,7 @@ char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { * * If the key is empty, a string key is created with the new string value * unless the new length value requested is zero. */ -int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { +int RM_StringTruncate(RedictModuleKey *key, size_t newlen) { if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_STRING) return REDISMODULE_ERR; if (newlen > 512*1024*1024) return REDISMODULE_ERR; @@ -4428,7 +4428,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { * * long n = RM_ValueLength(key); * for (long i = 0; i < n; i++) { - * RedisModuleString *elem = RedisModule_ListGet(key, i); + * RedictModuleString *elem = RedictModule_ListGet(key, i); * // Do stuff... * } * @@ -4447,7 +4447,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { * returned and key->iter, key->u.list.entry and key->u.list.index are set. On * failure, 0 is returned and errno is set as required by the list API * functions. */ -int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { +int moduleListIteratorSeek(RedictModuleKey *key, long index, int mode) { if (!key) { errno = EINVAL; return 0; @@ -4502,7 +4502,7 @@ int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { * - EBADF if the key is not opened for writing. * * Note: Before Redis 7.0, `errno` was not set by this function. */ -int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { +int RM_ListPush(RedictModuleKey *key, int where, RedictModuleString *ele) { if (!key || !ele) { errno = EINVAL; return REDISMODULE_ERR; @@ -4536,7 +4536,7 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { * - EBADF if the key is not opened for writing. * * Note: Before Redis 7.0, `errno` was not set by this function. */ -RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { +RedictModuleString *RM_ListPop(RedictModuleKey *key, int where) { if (!key) { errno = EINVAL; return NULL; @@ -4575,7 +4575,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { * - EBADF if the key is not opened for reading. * - EDOM if the index is not a valid index in the list. */ -RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { +RedictModuleString *RM_ListGet(RedictModuleKey *key, long index) { if (moduleListIteratorSeek(key, index, REDISMODULE_READ)) { robj *elem = listTypeGet(&key->u.list.entry); robj *decoded = getDecodedObject(elem); @@ -4602,7 +4602,7 @@ RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { +int RM_ListSet(RedictModuleKey *key, long index, RedictModuleString *value) { if (!value) { errno = EINVAL; return REDISMODULE_ERR; @@ -4638,7 +4638,7 @@ int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListInsert(RedisModuleKey *key, long index, RedisModuleString *value) { +int RM_ListInsert(RedictModuleKey *key, long index, RedictModuleString *value) { if (!value) { errno = EINVAL; return REDISMODULE_ERR; @@ -4680,7 +4680,7 @@ int RM_ListInsert(RedisModuleKey *key, long index, RedisModuleString *value) { * - EBADF if the key is not opened for writing. * - EDOM if the index is not a valid index in the list. */ -int RM_ListDelete(RedisModuleKey *key, long index) { +int RM_ListDelete(RedictModuleKey *key, long index) { if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { listTypeDelete(key->iter, &key->u.list.entry); if (moduleDelKeyIfEmpty(key)) return REDISMODULE_OK; @@ -4767,7 +4767,7 @@ int moduleZsetAddFlagsFromCoreFlags(int flags) { * * The key is of the wrong type. * * 'score' double value is not a number (NaN). */ -int RM_ZsetAdd(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) { +int RM_ZsetAdd(RedictModuleKey *key, double score, RedictModuleString *ele, int *flagsptr) { int in_flags = 0, out_flags = 0; if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; @@ -4795,7 +4795,7 @@ int RM_ZsetAdd(RedisModuleKey *key, double score, RedisModuleString *ele, int *f * This function has an additional field 'newscore', if not NULL is filled * with the new score of the element after the increment, if no error * is returned. */ -int RM_ZsetIncrby(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) { +int RM_ZsetIncrby(RedictModuleKey *key, double score, RedictModuleString *ele, int *flagsptr, double *newscore) { int in_flags = 0, out_flags = 0; if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; @@ -4829,7 +4829,7 @@ int RM_ZsetIncrby(RedisModuleKey *key, double score, RedisModuleString *ele, int * to know if the element was really removed. * * Empty keys will be handled correctly by doing nothing. */ -int RM_ZsetRem(RedisModuleKey *key, RedisModuleString *ele, int *deleted) { +int RM_ZsetRem(RedictModuleKey *key, RedictModuleString *ele, int *deleted) { if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; if (key->value != NULL && zsetDel(key->value,ele->ptr)) { @@ -4849,7 +4849,7 @@ int RM_ZsetRem(RedisModuleKey *key, RedisModuleString *ele, int *deleted) { * * The key is not a sorted set. * * The key is an open empty key. */ -int RM_ZsetScore(RedisModuleKey *key, RedisModuleString *ele, double *score) { +int RM_ZsetScore(RedictModuleKey *key, RedictModuleString *ele, double *score) { if (key->value == NULL) return REDISMODULE_ERR; if (key->value->type != OBJ_ZSET) return REDISMODULE_ERR; if (zsetScore(key->value,ele->ptr,score) == C_ERR) return REDISMODULE_ERR; @@ -4860,14 +4860,14 @@ int RM_ZsetScore(RedisModuleKey *key, RedisModuleString *ele, double *score) { * ## Key API for Sorted Set iterator * -------------------------------------------------------------------------- */ -void zsetKeyReset(RedisModuleKey *key) { +void zsetKeyReset(RedictModuleKey *key) { key->u.zset.type = REDISMODULE_ZSET_RANGE_NONE; key->u.zset.current = NULL; key->u.zset.er = 1; } /* Stop a sorted set iteration. */ -void RM_ZsetRangeStop(RedisModuleKey *key) { +void RM_ZsetRangeStop(RedictModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return; /* Free resources if needed. */ if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) @@ -4879,7 +4879,7 @@ void RM_ZsetRangeStop(RedisModuleKey *key) { } /* Return the "End of range" flag value to signal the end of the iteration. */ -int RM_ZsetRangeEndReached(RedisModuleKey *key) { +int RM_ZsetRangeEndReached(RedictModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 1; return key->u.zset.er; } @@ -4890,7 +4890,7 @@ int RM_ZsetRangeEndReached(RedisModuleKey *key) { * first element in the range is used as a starting point for the iterator * otherwise the last. Return REDISMODULE_OK on success otherwise * REDISMODULE_ERR. */ -int zsetInitScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex, int first) { +int zsetInitScoreRange(RedictModuleKey *key, double min, double max, int minex, int maxex, int first) { if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; RM_ZsetRangeStop(key); @@ -4935,13 +4935,13 @@ int zsetInitScoreRange(RedisModuleKey *key, double min, double max, int minex, i * 'minex' and 'maxex' parameters, if true, respectively setup a range * where the min and max value are exclusive (not included) instead of * inclusive. */ -int RM_ZsetFirstInScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex) { +int RM_ZsetFirstInScoreRange(RedictModuleKey *key, double min, double max, int minex, int maxex) { return zsetInitScoreRange(key,min,max,minex,maxex,1); } -/* Exactly like RedisModule_ZsetFirstInScoreRange() but the last element of +/* Exactly like RedictModule_ZsetFirstInScoreRange() but the last element of * the range is selected for the start of the iteration instead. */ -int RM_ZsetLastInScoreRange(RedisModuleKey *key, double min, double max, int minex, int maxex) { +int RM_ZsetLastInScoreRange(RedictModuleKey *key, double min, double max, int minex, int maxex) { return zsetInitScoreRange(key,min,max,minex,maxex,0); } @@ -4954,7 +4954,7 @@ int RM_ZsetLastInScoreRange(RedisModuleKey *key, double min, double max, int min * * Note that this function takes 'min' and 'max' in the same form of the * Redis ZRANGEBYLEX command. */ -int zsetInitLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max, int first) { +int zsetInitLexRange(RedictModuleKey *key, RedictModuleString *min, RedictModuleString *max, int first) { if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; RM_ZsetRangeStop(key); @@ -4993,25 +4993,25 @@ int zsetInitLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleStr * 1. The value stored at key is not a sorted set or the key is empty. * 2. The lexicographical range 'min' and 'max' format is invalid. * - * 'min' and 'max' should be provided as two RedisModuleString objects + * 'min' and 'max' should be provided as two RedictModuleString objects * in the same format as the parameters passed to the ZRANGEBYLEX command. * The function does not take ownership of the objects, so they can be released * ASAP after the iterator is setup. */ -int RM_ZsetFirstInLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) { +int RM_ZsetFirstInLexRange(RedictModuleKey *key, RedictModuleString *min, RedictModuleString *max) { return zsetInitLexRange(key,min,max,1); } -/* Exactly like RedisModule_ZsetFirstInLexRange() but the last element of +/* Exactly like RedictModule_ZsetFirstInLexRange() but the last element of * the range is selected for the start of the iteration instead. */ -int RM_ZsetLastInLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) { +int RM_ZsetLastInLexRange(RedictModuleKey *key, RedictModuleString *min, RedictModuleString *max) { return zsetInitLexRange(key,min,max,0); } /* Return the current sorted set element of an active sorted set iterator * or NULL if the range specified in the iterator does not include any * element. */ -RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score) { - RedisModuleString *str; +RedictModuleString *RM_ZsetRangeCurrentElement(RedictModuleKey *key, double *score) { + RedictModuleString *str; if (!key->value || key->value->type != OBJ_ZSET) return NULL; if (key->u.zset.current == NULL) return NULL; @@ -5038,7 +5038,7 @@ RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score /* Go to the next element of the sorted set iterator. Returns 1 if there was * a next element, 0 if we are already at the latest element or the range * does not include any item at all. */ -int RM_ZsetRangeNext(RedisModuleKey *key) { +int RM_ZsetRangeNext(RedictModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 0; if (!key->u.zset.type || !key->u.zset.current) return 0; /* No active iterator. */ @@ -5102,7 +5102,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { /* Go to the previous element of the sorted set iterator. Returns 1 if there was * a previous element, 0 if we are already at the first element or the range * does not include any item at all. */ -int RM_ZsetRangePrev(RedisModuleKey *key) { +int RM_ZsetRangePrev(RedictModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 0; if (!key->u.zset.type || !key->u.zset.current) return 0; /* No active iterator. */ @@ -5174,19 +5174,19 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * hash value, in order to set the specified field. * * The function is variadic and the user must specify pairs of field - * names and values, both as RedisModuleString pointers (unless the + * names and values, both as RedictModuleString pointers (unless the * CFIELD option is set, see later). At the end of the field/value-ptr pairs, * NULL must be specified as last argument to signal the end of the arguments * in the variadic function. * * Example to set the hash argv[1] to the value argv[2]: * - * RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1],argv[2],NULL); + * RedictModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1],argv[2],NULL); * * The function can also be used in order to delete fields (if they exist) * by setting them to the specified value of REDISMODULE_HASH_DELETE: * - * RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1], + * RedictModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1], * REDISMODULE_HASH_DELETE,NULL); * * The behavior of the command changes with the specified flags, that can be @@ -5199,7 +5199,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * associated to an existing filed, but no new fields * are created. * REDISMODULE_HASH_CFIELDS: The field names passed are null terminated C - * strings instead of RedisModuleString objects. + * strings instead of RedictModuleString objects. * REDISMODULE_HASH_COUNT_ALL: Include the number of inserted fields in the * returned number, in addition to the number of * updated and deleted fields. (Added in Redis @@ -5212,7 +5212,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * normal C strings, so for example to delete the field "foo" the following * code can be used: * - * RedisModule_HashSet(key,REDISMODULE_HASH_CFIELDS,"foo", + * RedictModule_HashSet(key,REDISMODULE_HASH_CFIELDS,"foo", * REDISMODULE_HASH_DELETE,NULL); * * Return value: @@ -5236,7 +5236,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * between Redis 6.2 and older versions. Modules that use it should determine * the Redis version and handle it accordingly. */ -int RM_HashSet(RedisModuleKey *key, int flags, ...) { +int RM_HashSet(RedictModuleKey *key, int flags, ...) { va_list ap; if (!key || (flags & ~(REDISMODULE_HASH_NX | REDISMODULE_HASH_XX | @@ -5256,17 +5256,17 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) { int count = 0; va_start(ap, flags); while(1) { - RedisModuleString *field, *value; + RedictModuleString *field, *value; /* Get the field and value objects. */ if (flags & REDISMODULE_HASH_CFIELDS) { char *cfield = va_arg(ap,char*); if (cfield == NULL) break; field = createRawStringObject(cfield,strlen(cfield)); } else { - field = va_arg(ap,RedisModuleString*); + field = va_arg(ap,RedictModuleString*); if (field == NULL) break; } - value = va_arg(ap,RedisModuleString*); + value = va_arg(ap,RedictModuleString*); /* Handle XX and NX */ if (flags & (REDISMODULE_HASH_XX|REDISMODULE_HASH_NX)) { @@ -5312,53 +5312,53 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) { } /* Get fields from a hash value. This function is called using a variable - * number of arguments, alternating a field name (as a RedisModuleString - * pointer) with a pointer to a RedisModuleString pointer, that is set to the + * number of arguments, alternating a field name (as a RedictModuleString + * pointer) with a pointer to a RedictModuleString pointer, that is set to the * value of the field if the field exists, or NULL if the field does not exist. * At the end of the field/value-ptr pairs, NULL must be specified as last * argument to signal the end of the arguments in the variadic function. * * This is an example usage: * - * RedisModuleString *first, *second; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_NONE,argv[1],&first, + * RedictModuleString *first, *second; + * RedictModule_HashGet(mykey,REDISMODULE_HASH_NONE,argv[1],&first, * argv[2],&second,NULL); * - * As with RedisModule_HashSet() the behavior of the command can be specified + * As with RedictModule_HashSet() the behavior of the command can be specified * passing flags different than REDISMODULE_HASH_NONE: * * REDISMODULE_HASH_CFIELDS: field names as null terminated C strings. * * REDISMODULE_HASH_EXISTS: instead of setting the value of the field - * expecting a RedisModuleString pointer to pointer, the function just + * expecting a RedictModuleString pointer to pointer, the function just * reports if the field exists or not and expects an integer pointer * as the second element of each pair. * * Example of REDISMODULE_HASH_CFIELDS: * - * RedisModuleString *username, *hashedpass; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); + * RedictModuleString *username, *hashedpass; + * RedictModule_HashGet(mykey,REDISMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); * * Example of REDISMODULE_HASH_EXISTS: * * int exists; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_EXISTS,argv[1],&exists,NULL); + * RedictModule_HashGet(mykey,REDISMODULE_HASH_EXISTS,argv[1],&exists,NULL); * * The function returns REDISMODULE_OK on success and REDISMODULE_ERR if * the key is not a hash value. * * Memory management: * - * The returned RedisModuleString objects should be released with - * RedisModule_FreeString(), or by enabling automatic memory management. + * The returned RedictModuleString objects should be released with + * RedictModule_FreeString(), or by enabling automatic memory management. */ -int RM_HashGet(RedisModuleKey *key, int flags, ...) { +int RM_HashGet(RedictModuleKey *key, int flags, ...) { va_list ap; if (key->value && key->value->type != OBJ_HASH) return REDISMODULE_ERR; va_start(ap, flags); while(1) { - RedisModuleString *field, **valueptr; + RedictModuleString *field, **valueptr; int *existsptr; /* Get the field object and the value pointer to pointer. */ if (flags & REDISMODULE_HASH_CFIELDS) { @@ -5366,7 +5366,7 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { if (cfield == NULL) break; field = createRawStringObject(cfield,strlen(cfield)); } else { - field = va_arg(ap,RedisModuleString*); + field = va_arg(ap,RedictModuleString*); if (field == NULL) break; } @@ -5378,7 +5378,7 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { else *existsptr = 0; } else { - valueptr = va_arg(ap,RedisModuleString**); + valueptr = va_arg(ap,RedictModuleString**); if (key->value) { *valueptr = hashTypeGetValueObject(key->value,field->ptr); if (*valueptr) { @@ -5405,13 +5405,13 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * * For an introduction to streams, see https://redis.io/topics/streams-intro. * - * The type RedisModuleStreamID, which is used in stream functions, is a struct + * The type RedictModuleStreamID, which is used in stream functions, is a struct * with two 64-bit fields and is defined as * - * typedef struct RedisModuleStreamID { + * typedef struct RedictModuleStreamID { * uint64_t ms; * uint64_t seq; - * } RedisModuleStreamID; + * } RedictModuleStreamID; * * See also RM_ValueLength(), which returns the length of a stream, and the * conversion functions RM_StringToStreamID() and RM_CreateStringFromStreamID(). @@ -5441,7 +5441,7 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * - EFBIG if the stream has reached the last possible ID * - ERANGE if the elements are too large to be stored. */ -int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisModuleString **argv, long numfields) { +int RM_StreamAdd(RedictModuleKey *key, int flags, RedictModuleStreamID *id, RedictModuleString **argv, long numfields) { /* Validate args */ if (!key || (numfields != 0 && !argv) || /* invalid key or argv */ (flags & ~(REDISMODULE_STREAM_ADD_AUTOID)) || /* invalid flags */ @@ -5520,7 +5520,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * See also RM_StreamIteratorDelete() for deleting the current entry while * iterating using a stream iterator. */ -int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { +int RM_StreamDelete(RedictModuleKey *key, RedictModuleStreamID *id) { if (!key || !id) { errno = EINVAL; return REDISMODULE_ERR; @@ -5544,7 +5544,7 @@ int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { /* Sets up a stream iterator. * - * - `key`: The stream key opened for reading using RedisModule_OpenKey(). + * - `key`: The stream key opened for reading using RedictModule_OpenKey(). * - `flags`: * - `REDISMODULE_STREAM_ITERATOR_EXCLUSIVE`: Don't include `start` and `end` * in the iterated range. @@ -5567,31 +5567,31 @@ int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { * Returns REDISMODULE_OK on success and REDISMODULE_ERR if the key doesn't * refer to a stream or if invalid arguments were given. * - * The stream IDs are retrieved using RedisModule_StreamIteratorNextID() and + * The stream IDs are retrieved using RedictModule_StreamIteratorNextID() and * for each stream ID, the fields and values are retrieved using - * RedisModule_StreamIteratorNextField(). The iterator is freed by calling - * RedisModule_StreamIteratorStop(). + * RedictModule_StreamIteratorNextField(). The iterator is freed by calling + * RedictModule_StreamIteratorStop(). * * Example (error handling omitted): * - * RedisModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); - * RedisModuleStreamID id; + * RedictModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); + * RedictModuleStreamID id; * long numfields; - * while (RedisModule_StreamIteratorNextID(key, &id, &numfields) == + * while (RedictModule_StreamIteratorNextID(key, &id, &numfields) == * REDISMODULE_OK) { - * RedisModuleString *field, *value; - * while (RedisModule_StreamIteratorNextField(key, &field, &value) == + * RedictModuleString *field, *value; + * while (RedictModule_StreamIteratorNextField(key, &field, &value) == * REDISMODULE_OK) { * // * // ... Do stuff ... * // - * RedisModule_FreeString(ctx, field); - * RedisModule_FreeString(ctx, value); + * RedictModule_FreeString(ctx, field); + * RedictModule_FreeString(ctx, value); * } * } - * RedisModule_StreamIteratorStop(key); + * RedictModule_StreamIteratorStop(key); */ -int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID *start, RedisModuleStreamID *end) { +int RM_StreamIteratorStart(RedictModuleKey *key, int flags, RedictModuleStreamID *start, RedictModuleStreamID *end) { /* check args */ if (!key || (flags & ~(REDISMODULE_STREAM_ITERATOR_EXCLUSIVE | @@ -5630,7 +5630,7 @@ int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID * return REDISMODULE_OK; } -/* Stops a stream iterator created using RedisModule_StreamIteratorStart() and +/* Stops a stream iterator created using RedictModule_StreamIteratorStart() and * reclaims its memory. * * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned @@ -5642,7 +5642,7 @@ int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID * * - EBADF if the key was not opened for writing or if no stream iterator is * associated with the key */ -int RM_StreamIteratorStop(RedisModuleKey *key) { +int RM_StreamIteratorStop(RedictModuleKey *key) { if (!key) { errno = EINVAL; return REDISMODULE_ERR; @@ -5663,7 +5663,7 @@ int RM_StreamIteratorStop(RedisModuleKey *key) { * fields. * * - `key`: Key for which a stream iterator has been started using - * RedisModule_StreamIteratorStart(). + * RedictModule_StreamIteratorStart(). * - `id`: The stream ID returned. NULL if you don't care. * - `numfields`: The number of fields in the found stream entry. NULL if you * don't care. @@ -5681,10 +5681,10 @@ int RM_StreamIteratorStop(RedisModuleKey *key) { * to RM_StreamIteratorStart() and with the same key, it is safe to assume that * an REDISMODULE_ERR return value means that there are no more entries. * - * Use RedisModule_StreamIteratorNextField() to retrieve the fields and values. - * See the example at RedisModule_StreamIteratorStart(). + * Use RedictModule_StreamIteratorNextField() to retrieve the fields and values. + * See the example at RedictModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) { +int RM_StreamIteratorNextID(RedictModuleKey *key, RedictModuleStreamID *id, long *numfields) { if (!key) { errno = EINVAL; return REDISMODULE_ERR; @@ -5717,14 +5717,14 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * /* Retrieves the next field of the current stream ID and its corresponding value * in a stream iteration. This function should be called repeatedly after calling - * RedisModule_StreamIteratorNextID() to fetch each field-value pair. + * RedictModule_StreamIteratorNextID() to fetch each field-value pair. * * - `key`: Key where a stream iterator has been started. * - `field_ptr`: This is where the field is returned. * - `value_ptr`: This is where the value is returned. * * Returns REDISMODULE_OK and points `*field_ptr` and `*value_ptr` to freshly - * allocated RedisModuleString objects. The string objects are freed + * allocated RedictModuleString objects. The string objects are freed * automatically when the callback finishes if automatic memory is enabled. On * failure, REDISMODULE_ERR is returned and `errno` is set as follows: * @@ -5738,9 +5738,9 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * * call to RM_StreamIteratorNextID() and with the same key, it is safe to assume * that an REDISMODULE_ERR return value means that there are no more fields. * - * See the example at RedisModule_StreamIteratorStart(). + * See the example at RedictModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) { +int RM_StreamIteratorNextField(RedictModuleKey *key, RedictModuleString **field_ptr, RedictModuleString **value_ptr) { if (!key) { errno = EINVAL; return REDISMODULE_ERR; @@ -5783,7 +5783,7 @@ int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_pt * - EBADF if the key is not opened for writing, if no iterator has been started * - ENOENT if the iterator has no current stream entry */ -int RM_StreamIteratorDelete(RedisModuleKey *key) { +int RM_StreamIteratorDelete(RedictModuleKey *key) { if (!key) { errno = EINVAL; return REDISMODULE_ERR; @@ -5821,7 +5821,7 @@ int RM_StreamIteratorDelete(RedisModuleKey *key) { * - ENOTSUP if the key is empty or of a type other than stream * - EBADF if the key is not opened for writing */ -long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length) { +long long RM_StreamTrimByLength(RedictModuleKey *key, int flags, long long length) { if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || length < 0) { errno = EINVAL; return -1; @@ -5851,7 +5851,7 @@ long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length * - ENOTSUP if the key is empty or of a type other than stream * - EBADF if the key is not opened for writing */ -long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID *id) { +long long RM_StreamTrimByID(RedictModuleKey *key, int flags, RedictModuleStreamID *id) { if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || !id) { errno = EINVAL; return -1; @@ -5874,26 +5874,26 @@ long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID * -------------------------------------------------------------------------- */ -void moduleParseCallReply_Int(RedisModuleCallReply *reply); -void moduleParseCallReply_BulkString(RedisModuleCallReply *reply); -void moduleParseCallReply_SimpleString(RedisModuleCallReply *reply); -void moduleParseCallReply_Array(RedisModuleCallReply *reply); +void moduleParseCallReply_Int(RedictModuleCallReply *reply); +void moduleParseCallReply_BulkString(RedictModuleCallReply *reply); +void moduleParseCallReply_SimpleString(RedictModuleCallReply *reply); +void moduleParseCallReply_Array(RedictModuleCallReply *reply); /* Free a Call reply and all the nested replies it contains if it's an * array. */ -void RM_FreeCallReply(RedisModuleCallReply *reply) { +void RM_FreeCallReply(RedictModuleCallReply *reply) { /* This is a wrapper for the recursive free reply function. This is needed * in order to have the first level function to return on nested replies, * but only if called by the module API. */ - RedisModuleCtx *ctx = NULL; + RedictModuleCtx *ctx = NULL; if(callReplyType(reply) == REDISMODULE_REPLY_PROMISE) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); + RedictModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); ctx = promise->ctx; - freeRedisModuleAsyncRMCallPromise(promise); + freeRedictModuleAsyncRMCallPromise(promise); } else { ctx = callReplyGetPrivateData(reply); } @@ -5920,50 +5920,50 @@ void RM_FreeCallReply(RedisModuleCallReply *reply) { * - REDISMODULE_REPLY_VERBATIM_STRING * - REDISMODULE_REPLY_ATTRIBUTE * - REDISMODULE_REPLY_PROMISE */ -int RM_CallReplyType(RedisModuleCallReply *reply) { +int RM_CallReplyType(RedictModuleCallReply *reply) { return callReplyType(reply); } /* Return the reply type length, where applicable. */ -size_t RM_CallReplyLength(RedisModuleCallReply *reply) { +size_t RM_CallReplyLength(RedictModuleCallReply *reply) { return callReplyGetLen(reply); } /* Return the 'idx'-th nested call reply element of an array reply, or NULL * if the reply type is wrong or the index is out of range. */ -RedisModuleCallReply *RM_CallReplyArrayElement(RedisModuleCallReply *reply, size_t idx) { +RedictModuleCallReply *RM_CallReplyArrayElement(RedictModuleCallReply *reply, size_t idx) { return callReplyGetArrayElement(reply, idx); } /* Return the `long long` of an integer reply. */ -long long RM_CallReplyInteger(RedisModuleCallReply *reply) { +long long RM_CallReplyInteger(RedictModuleCallReply *reply) { return callReplyGetLongLong(reply); } /* Return the double value of a double reply. */ -double RM_CallReplyDouble(RedisModuleCallReply *reply) { +double RM_CallReplyDouble(RedictModuleCallReply *reply) { return callReplyGetDouble(reply); } /* Return the big number value of a big number reply. */ -const char *RM_CallReplyBigNumber(RedisModuleCallReply *reply, size_t *len) { +const char *RM_CallReplyBigNumber(RedictModuleCallReply *reply, size_t *len) { return callReplyGetBigNumber(reply, len); } /* Return the value of a verbatim string reply, * An optional output argument can be given to get verbatim reply format. */ -const char *RM_CallReplyVerbatim(RedisModuleCallReply *reply, size_t *len, const char **format) { +const char *RM_CallReplyVerbatim(RedictModuleCallReply *reply, size_t *len, const char **format) { return callReplyGetVerbatim(reply, len, format); } /* Return the Boolean value of a Boolean reply. */ -int RM_CallReplyBool(RedisModuleCallReply *reply) { +int RM_CallReplyBool(RedictModuleCallReply *reply) { return callReplyGetBool(reply); } /* Return the 'idx'-th nested call reply element of a set reply, or NULL * if the reply type is wrong or the index is out of range. */ -RedisModuleCallReply *RM_CallReplySetElement(RedisModuleCallReply *reply, size_t idx) { +RedictModuleCallReply *RM_CallReplySetElement(RedictModuleCallReply *reply, size_t idx) { return callReplyGetSetElement(reply, idx); } @@ -5975,7 +5975,7 @@ RedisModuleCallReply *RM_CallReplySetElement(RedisModuleCallReply *reply, size_t * * The `key` and `value` arguments are used to return by reference, and may be * NULL if not required. */ -int RM_CallReplyMapElement(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) { +int RM_CallReplyMapElement(RedictModuleCallReply *reply, size_t idx, RedictModuleCallReply **key, RedictModuleCallReply **val) { if (callReplyGetMapElement(reply, idx, key, val) == C_OK){ return REDISMODULE_OK; } @@ -5983,7 +5983,7 @@ int RM_CallReplyMapElement(RedisModuleCallReply *reply, size_t idx, RedisModuleC } /* Return the attribute of the given reply, or NULL if no attribute exists. */ -RedisModuleCallReply *RM_CallReplyAttribute(RedisModuleCallReply *reply) { +RedictModuleCallReply *RM_CallReplyAttribute(RedictModuleCallReply *reply) { return callReplyGetAttribute(reply); } @@ -5995,22 +5995,22 @@ RedisModuleCallReply *RM_CallReplyAttribute(RedisModuleCallReply *reply) { * * The `key` and `value` arguments are used to return by reference, and may be * NULL if not required. */ -int RM_CallReplyAttributeElement(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) { +int RM_CallReplyAttributeElement(RedictModuleCallReply *reply, size_t idx, RedictModuleCallReply **key, RedictModuleCallReply **val) { if (callReplyGetAttributeElement(reply, idx, key, val) == C_OK){ return REDISMODULE_OK; } return REDISMODULE_ERR; } -/* Set unblock handler (callback and private data) on the given promise RedisModuleCallReply. +/* Set unblock handler (callback and private data) on the given promise RedictModuleCallReply. * The given reply must be of promise type (REDISMODULE_REPLY_PROMISE). */ -void RM_CallReplyPromiseSetUnblockHandler(RedisModuleCallReply *reply, RedisModuleOnUnblocked on_unblock, void *private_data) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); +void RM_CallReplyPromiseSetUnblockHandler(RedictModuleCallReply *reply, RedictModuleOnUnblocked on_unblock, void *private_data) { + RedictModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); promise->on_unblocked = on_unblock; promise->private_data = private_data; } -/* Abort the execution of a given promise RedisModuleCallReply. +/* Abort the execution of a given promise RedictModuleCallReply. * return REDMODULE_OK in case the abort was done successfully and REDISMODULE_ERR * if its not possible to abort the execution (execution already finished). * In case the execution was aborted (REDMODULE_OK was returned), the private_data out parameter @@ -6021,8 +6021,8 @@ void RM_CallReplyPromiseSetUnblockHandler(RedisModuleCallReply *reply, RedisModu * That said, it is possible that the abort operation will successes but the operation will still continue. * This can happened if, for example, a module implements some blocking command and does not respect the * disconnect callback. For pure Redis commands this can not happened.*/ -int RM_CallReplyPromiseAbort(RedisModuleCallReply *reply, void **private_data) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); +int RM_CallReplyPromiseAbort(RedictModuleCallReply *reply, void **private_data) { + RedictModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); if (!promise->c) return REDISMODULE_ERR; /* Promise can not be aborted, either already aborted or already finished. */ if (!(promise->c->flags & CLIENT_BLOCKED)) return REDISMODULE_ERR; /* Client is not blocked anymore, can not abort it. */ @@ -6036,7 +6036,7 @@ int RM_CallReplyPromiseAbort(RedisModuleCallReply *reply, void **private_data) { } /* Return the pointer and length of a string or error reply. */ -const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { +const char *RM_CallReplyStringPtr(RedictModuleCallReply *reply, size_t *len) { size_t private_len; if (!len) len = &private_len; return callReplyGetString(reply, len); @@ -6044,8 +6044,8 @@ const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { /* Return a new string object from a call reply of type string, error or * integer. Otherwise (wrong reply type) return NULL. */ -RedisModuleString *RM_CreateStringFromCallReply(RedisModuleCallReply *reply) { - RedisModuleCtx* ctx = callReplyGetPrivateData(reply); +RedictModuleString *RM_CreateStringFromCallReply(RedictModuleCallReply *reply) { + RedictModuleCtx* ctx = callReplyGetPrivateData(reply); size_t len; const char *str; switch(callReplyType(reply)) { @@ -6064,7 +6064,7 @@ RedisModuleString *RM_CreateStringFromCallReply(RedisModuleCallReply *reply) { } /* Modifies the user that RM_Call will use (e.g. for ACL checks) */ -void RM_SetContextUser(RedisModuleCtx *ctx, const RedisModuleUser *user) { +void RM_SetContextUser(RedictModuleCtx *ctx, const RedictModuleUser *user) { ctx->user = user; } @@ -6186,15 +6186,15 @@ fmterr: * argument that is the buffer's length. * * `c` -- The argument is a pointer to a plain C string (null-terminated). * * `l` -- The argument is a `long long` integer. - * * `s` -- The argument is a RedisModuleString. - * * `v` -- The argument(s) is a vector of RedisModuleString. + * * `s` -- The argument is a RedictModuleString. + * * `v` -- The argument(s) is a vector of RedictModuleString. * * `!` -- Sends the Redis command and its arguments to replicas and AOF. * * `A` -- Suppress AOF propagation, send only to replicas (requires `!`). * * `R` -- Suppress replicas propagation, send only to AOF (requires `!`). * * `3` -- Return a RESP3 reply. This will change the command reply. * e.g., HGETALL returns a map instead of a flat array. * * `0` -- Return the reply in auto mode, i.e. the reply format will be the - * same as the client attached to the given RedisModuleCtx. This will + * same as the client attached to the given RedictModuleCtx. This will * probably used when you want to pass the reply directly to the client. * * `C` -- Run a command as the user attached to the context. * User is either attached automatically via the client that directly @@ -6215,7 +6215,7 @@ fmterr: * or when the server is unable to persist to the disk. * * `W` -- Do not allow to run any write command (flagged with the `write` flag). * * `M` -- Do not allow `deny-oom` flagged commands when over the memory limit. - * * `E` -- Return error as RedisModuleCallReply. If there is an error before + * * `E` -- Return error as RedictModuleCallReply. If there is an error before * invoking the command, the error is returned using errno mechanism. * This flag allows to get the error also as an error CallReply with * relevant error message. @@ -6227,13 +6227,13 @@ fmterr: * special REDISMODULE_REPLY_PROMISE will be returned. This reply type * indicates that the command was blocked and the reply will be given asynchronously. * The module can use this reply object to set a handler which will be called when - * the command gets unblocked using RedisModule_CallReplyPromiseSetUnblockHandler. + * the command gets unblocked using RedictModule_CallReplyPromiseSetUnblockHandler. * The handler must be set immediately after the command invocation (without releasing * the Redis lock in between). If the handler is not set, the blocking command will * still continue its execution but the reply will be ignored (fire and forget), * notice that this is dangerous in case of role change, as explained below. - * The module can use RedisModule_CallReplyPromiseAbort to abort the command invocation - * if it was not yet finished (see RedisModule_CallReplyPromiseAbort documentation for more + * The module can use RedictModule_CallReplyPromiseAbort to abort the command invocation + * if it was not yet finished (see RedictModule_CallReplyPromiseAbort documentation for more * details). It is also the module's responsibility to abort the execution on role change, either by using * server event (to get notified when the instance becomes a replica) or relying on the disconnect * callback of the original client. Failing to do so can result in a write operation on a replica. @@ -6253,7 +6253,7 @@ fmterr: * * * **...**: The actual arguments to the Redis command. * - * On success a RedisModuleCallReply object is returned, otherwise + * On success a RedictModuleCallReply object is returned, otherwise * NULL is returned and errno is set to the following values: * * * EBADF: wrong format specifier. @@ -6270,22 +6270,22 @@ fmterr: * * Example code fragment: * - * reply = RedisModule_Call(ctx,"INCRBY","sc",argv[1],"10"); - * if (RedisModule_CallReplyType(reply) == REDISMODULE_REPLY_INTEGER) { - * long long myval = RedisModule_CallReplyInteger(reply); + * reply = RedictModule_Call(ctx,"INCRBY","sc",argv[1],"10"); + * if (RedictModule_CallReplyType(reply) == REDISMODULE_REPLY_INTEGER) { + * long long myval = RedictModule_CallReplyInteger(reply); * // Do something with myval. * } * * This API is documented here: https://redis.io/topics/modules-intro */ -RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { +RedictModuleCallReply *RM_Call(RedictModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { client *c = NULL; robj **argv = NULL; int argc = 0, flags = 0; va_list ap; - RedisModuleCallReply *reply = NULL; + RedictModuleCallReply *reply = NULL; int replicate = 0; /* Replicate this command? */ - int error_as_call_replies = 0; /* return errors as RedisModuleCallReply object */ + int error_as_call_replies = 0; /* return errors as RedictModuleCallReply object */ uint64_t cmd_flags; /* Handle arguments. */ @@ -6550,8 +6550,8 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch if (c->flags & CLIENT_BLOCKED) { serverAssert(flags & REDISMODULE_ARGV_ALLOW_BLOCK); serverAssert(ctx->module); - RedisModuleAsyncRMCallPromise *promise = zmalloc(sizeof(RedisModuleAsyncRMCallPromise)); - *promise = (RedisModuleAsyncRMCallPromise) { + RedictModuleAsyncRMCallPromise *promise = zmalloc(sizeof(RedictModuleAsyncRMCallPromise)); + *promise = (RedictModuleAsyncRMCallPromise) { /* We start with ref_count value of 2 because this object is held * by the promise CallReply and the fake client that was used to execute the command. */ .ref_count = 2, @@ -6585,7 +6585,7 @@ cleanup: /* Return a pointer, and a length, to the protocol returned by the command * that returned the reply object. */ -const char *RM_CallReplyProto(RedisModuleCallReply *reply, size_t *len) { +const char *RM_CallReplyProto(RedictModuleCallReply *reply, size_t *len) { return callReplyGetProto(reply, len); } @@ -6653,7 +6653,7 @@ moduleType *moduleTypeLookupModuleByNameInternal(const char *name, int ignore_ca dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6703,7 +6703,7 @@ moduleType *moduleTypeLookupModuleByID(uint64_t id) { dictEntry *de; while ((de = dictNext(di)) != NULL && mt == NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6752,9 +6752,9 @@ const char *moduleTypeModuleName(moduleType *mt) { /* Return the module name from a module command */ const char *moduleNameFromCommand(struct redictCommand *cmd) { - serverAssert(cmd->proc == RedisModuleCommandDispatcher); + serverAssert(cmd->proc == RedictModuleCommandDispatcher); - RedisModuleCommand *cp = cmd->module_cmd; + RedictModuleCommand *cp = cmd->module_cmd; return cp->module->name; } @@ -6770,7 +6770,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj } void *newval = NULL; if (mt->copy2 != NULL) { - RedisModuleKeyOptCtx ctx = {fromkey, tokey, c->db->id, todb}; + RedictModuleKeyOptCtx ctx = {fromkey, tokey, c->db->id, todb}; newval = mt->copy2(&ctx, mv->value); } else { newval = mt->copy(fromkey, tokey, mv->value); @@ -6805,11 +6805,11 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * callback is able to check the encver value and act accordingly. * The encver must be a positive value between 0 and 1023. * - * * **typemethods_ptr** is a pointer to a RedisModuleTypeMethods structure + * * **typemethods_ptr** is a pointer to a RedictModuleTypeMethods structure * that should be populated with the methods callbacks and structure * version, like in the following example: * - * RedisModuleTypeMethods tm = { + * RedictModuleTypeMethods tm = { * .version = REDISMODULE_TYPE_METHOD_VERSION, * .rdb_load = myType_RDBLoadCallBack, * .rdb_save = myType_RDBSaveCallBack, @@ -6849,7 +6849,7 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * * **unlink**: A callback function pointer that used to notifies the module that the key has * been removed from the DB by redis, and may soon be freed by a background thread. Note that * it won't be called on FLUSHALL/FLUSHDB (both sync and async), and the module can use the - * RedisModuleEvent_FlushDB to hook into that. + * RedictModuleEvent_FlushDB to hook into that. * * **copy**: A callback function pointer that is used to make a copy of the specified key. * The module is expected to perform a deep copy of the specified value and return it. * In addition, hints about the names of the source and destination keys is provided. @@ -6872,14 +6872,14 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * NOTE: The value is passed as a `void**` and the function is expected to update the * pointer if the top-level value pointer is defragmented and consequently changes. * - * * **mem_usage2**: Similar to `mem_usage`, but provides the `RedisModuleKeyOptCtx` parameter + * * **mem_usage2**: Similar to `mem_usage`, but provides the `RedictModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained, and * the `sample_size` for size estimation (see MEMORY USAGE command). - * * **free_effort2**: Similar to `free_effort`, but provides the `RedisModuleKeyOptCtx` parameter + * * **free_effort2**: Similar to `free_effort`, but provides the `RedictModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained. - * * **unlink2**: Similar to `unlink`, but provides the `RedisModuleKeyOptCtx` parameter + * * **unlink2**: Similar to `unlink`, but provides the `RedictModuleKeyOptCtx` parameter * so that meta information such as key name and db id can be obtained. - * * **copy2**: Similar to `copy`, but provides the `RedisModuleKeyOptCtx` parameter + * * **copy2**: Similar to `copy`, but provides the `RedictModuleKeyOptCtx` parameter * so that meta information such as key names and db ids can be obtained. * * **aux_save2**: Similar to `aux_save`, but with small semantic change, if the module * saves nothing on this callback then no data about this aux field will be written to the @@ -6888,23 +6888,23 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * Note: the module name "AAAAAAAAA" is reserved and produces an error, it * happens to be pretty lame as well. * - * If RedisModule_CreateDataType() is called outside of RedisModule_OnLoad() function, + * If RedictModule_CreateDataType() is called outside of RedictModule_OnLoad() function, * there is already a module registering a type with the same name, * or if the module name or encver is invalid, NULL is returned. * Otherwise the new type is registered into Redis, and a reference of - * type RedisModuleType is returned: the caller of the function should store + * type RedictModuleType is returned: the caller of the function should store * this reference into a global variable to make future use of it in the * modules type API, since a single module may register multiple types. * Example code fragment: * - * static RedisModuleType *BalancedTreeType; + * static RedictModuleType *BalancedTreeType; * - * int RedisModule_OnLoad(RedisModuleCtx *ctx) { + * int RedictModule_OnLoad(RedictModuleCtx *ctx) { * // some code here ... * BalancedTreeType = RM_CreateDataType(...); * } */ -moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { +moduleType *RM_CreateDataType(RedictModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { if (!ctx->module->onload) return NULL; uint64_t id = moduleTypeEncodeId(name,encver); @@ -6982,7 +6982,7 @@ moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, * as the value of the key, deleting the old value if any. * On success REDISMODULE_OK is returned. If the key is not open for * writing or there is an active iterator, REDISMODULE_ERR is returned. */ -int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) { +int RM_ModuleTypeSetValue(RedictModuleKey *key, moduleType *mt, void *value) { if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; RM_DeleteKey(key); robj *o = createModuleObject(mt,value); @@ -6992,12 +6992,12 @@ int RM_ModuleTypeSetValue(RedisModuleKey *key, moduleType *mt, void *value) { return REDISMODULE_OK; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming RedictModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on * the key, returns the module type pointer of the value stored at key. * * If the key is NULL, is not associated with a module type, or is empty, * then NULL is returned instead. */ -moduleType *RM_ModuleTypeGetType(RedisModuleKey *key) { +moduleType *RM_ModuleTypeGetType(RedictModuleKey *key) { if (key == NULL || key->value == NULL || RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; @@ -7005,13 +7005,13 @@ moduleType *RM_ModuleTypeGetType(RedisModuleKey *key) { return mv->type; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming RedictModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on * the key, returns the module type low-level value stored at key, as - * it was set by the user via RedisModule_ModuleTypeSetValue(). + * it was set by the user via RedictModule_ModuleTypeSetValue(). * * If the key is NULL, is not associated with a module type, or is empty, * then NULL is returned instead. */ -void *RM_ModuleTypeGetValue(RedisModuleKey *key) { +void *RM_ModuleTypeGetValue(RedictModuleKey *key) { if (key == NULL || key->value == NULL || RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; @@ -7026,7 +7026,7 @@ void *RM_ModuleTypeGetValue(RedisModuleKey *key) { /* Called when there is a load error in the context of a module. On some * modules this cannot be recovered, but if the module declared capability * to handle errors, we'll raise a flag rather than exiting. */ -void moduleRDBLoadError(RedisModuleIO *io) { +void moduleRDBLoadError(RedictModuleIO *io) { if (io->type->module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) { io->error = 1; return; @@ -7050,7 +7050,7 @@ int moduleAllDatatypesHandleErrors(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); if (listLength(module->types) && !(module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS)) { @@ -7070,7 +7070,7 @@ int moduleAllModulesHandleReplAsyncLoad(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); if (!(module->options & REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD)) { dictReleaseIterator(di); return 0; @@ -7082,12 +7082,12 @@ int moduleAllModulesHandleReplAsyncLoad(void) { /* Returns true if any previous IO API failed. * for `Load*` APIs the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with - * RedisModule_SetModuleOptions first. */ -int RM_IsIOError(RedisModuleIO *io) { + * RedictModule_SetModuleOptions first. */ +int RM_IsIOError(RedictModuleIO *io) { return io->error; } -static int flushRedisModuleIOBuffer(RedisModuleIO *io) { +static int flushRedictModuleIOBuffer(RedictModuleIO *io) { if (!io->pre_flush_buffer) return 0; /* We have data that must be flushed before saving the current data. @@ -7103,9 +7103,9 @@ static int flushRedisModuleIOBuffer(RedisModuleIO *io) { /* Save an unsigned 64 bit value into the RDB file. This function should only * be called in the context of the rdb_save method of modules implementing new * data types. */ -void RM_SaveUnsigned(RedisModuleIO *io, uint64_t value) { +void RM_SaveUnsigned(RedictModuleIO *io, uint64_t value) { if (io->error) return; - if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; + if (flushRedictModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ int retval = rdbSaveLen(io->rio, RDB_MODULE_OPCODE_UINT); if (retval == -1) goto saveerr; @@ -7123,7 +7123,7 @@ saveerr: /* Load an unsigned 64 bit value from the RDB file. This function should only * be called in the context of the `rdb_load` method of modules implementing * new data types. */ -uint64_t RM_LoadUnsigned(RedisModuleIO *io) { +uint64_t RM_LoadUnsigned(RedictModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_UINT) goto loaderr; @@ -7137,29 +7137,29 @@ loaderr: return 0; } -/* Like RedisModule_SaveUnsigned() but for signed 64 bit values. */ -void RM_SaveSigned(RedisModuleIO *io, int64_t value) { +/* Like RedictModule_SaveUnsigned() but for signed 64 bit values. */ +void RM_SaveSigned(RedictModuleIO *io, int64_t value) { union {uint64_t u; int64_t i;} conv; conv.i = value; RM_SaveUnsigned(io,conv.u); } -/* Like RedisModule_LoadUnsigned() but for signed 64 bit values. */ -int64_t RM_LoadSigned(RedisModuleIO *io) { +/* Like RedictModule_LoadUnsigned() but for signed 64 bit values. */ +int64_t RM_LoadSigned(RedictModuleIO *io) { union {uint64_t u; int64_t i;} conv; conv.u = RM_LoadUnsigned(io); return conv.i; } /* In the context of the rdb_save method of a module type, saves a - * string into the RDB file taking as input a RedisModuleString. + * string into the RDB file taking as input a RedictModuleString. * - * The string can be later loaded with RedisModule_LoadString() or + * The string can be later loaded with RedictModule_LoadString() or * other Load family functions expecting a serialized string inside * the RDB file. */ -void RM_SaveString(RedisModuleIO *io, RedisModuleString *s) { +void RM_SaveString(RedictModuleIO *io, RedictModuleString *s) { if (io->error) return; - if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; + if (flushRedictModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ ssize_t retval = rdbSaveLen(io->rio, RDB_MODULE_OPCODE_STRING); if (retval == -1) goto saveerr; @@ -7174,11 +7174,11 @@ saveerr: io->error = 1; } -/* Like RedisModule_SaveString() but takes a raw C pointer and length +/* Like RedictModule_SaveString() but takes a raw C pointer and length * as input. */ -void RM_SaveStringBuffer(RedisModuleIO *io, const char *str, size_t len) { +void RM_SaveStringBuffer(RedictModuleIO *io, const char *str, size_t len) { if (io->error) return; - if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; + if (flushRedictModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ ssize_t retval = rdbSaveLen(io->rio, RDB_MODULE_OPCODE_STRING); if (retval == -1) goto saveerr; @@ -7194,7 +7194,7 @@ saveerr: } /* Implements RM_LoadString() and RM_LoadStringBuffer() */ -void *moduleLoadString(RedisModuleIO *io, int plain, size_t *lenptr) { +void *moduleLoadString(RedictModuleIO *io, int plain, size_t *lenptr) { if (io->error) return NULL; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_STRING) goto loaderr; @@ -7209,35 +7209,35 @@ loaderr: } /* In the context of the rdb_load method of a module data type, loads a string - * from the RDB file, that was previously saved with RedisModule_SaveString() + * from the RDB file, that was previously saved with RedictModule_SaveString() * functions family. * - * The returned string is a newly allocated RedisModuleString object, and - * the user should at some point free it with a call to RedisModule_FreeString(). + * The returned string is a newly allocated RedictModuleString object, and + * the user should at some point free it with a call to RedictModule_FreeString(). * - * If the data structure does not store strings as RedisModuleString objects, - * the similar function RedisModule_LoadStringBuffer() could be used instead. */ -RedisModuleString *RM_LoadString(RedisModuleIO *io) { + * If the data structure does not store strings as RedictModuleString objects, + * the similar function RedictModule_LoadStringBuffer() could be used instead. */ +RedictModuleString *RM_LoadString(RedictModuleIO *io) { return moduleLoadString(io,0,NULL); } -/* Like RedisModule_LoadString() but returns a heap allocated string that - * was allocated with RedisModule_Alloc(), and can be resized or freed with - * RedisModule_Realloc() or RedisModule_Free(). +/* Like RedictModule_LoadString() but returns a heap allocated string that + * was allocated with RedictModule_Alloc(), and can be resized or freed with + * RedictModule_Realloc() or RedictModule_Free(). * * The size of the string is stored at '*lenptr' if not NULL. * The returned string is not automatically NULL terminated, it is loaded * exactly as it was stored inside the RDB file. */ -char *RM_LoadStringBuffer(RedisModuleIO *io, size_t *lenptr) { +char *RM_LoadStringBuffer(RedictModuleIO *io, size_t *lenptr) { return moduleLoadString(io,1,lenptr); } /* In the context of the rdb_save method of a module data type, saves a double * value to the RDB file. The double can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadDouble(). */ -void RM_SaveDouble(RedisModuleIO *io, double value) { + * It is possible to load back the value with RedictModule_LoadDouble(). */ +void RM_SaveDouble(RedictModuleIO *io, double value) { if (io->error) return; - if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; + if (flushRedictModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ int retval = rdbSaveLen(io->rio, RDB_MODULE_OPCODE_DOUBLE); if (retval == -1) goto saveerr; @@ -7253,8 +7253,8 @@ saveerr: } /* In the context of the rdb_save method of a module data type, loads back the - * double value saved by RedisModule_SaveDouble(). */ -double RM_LoadDouble(RedisModuleIO *io) { + * double value saved by RedictModule_SaveDouble(). */ +double RM_LoadDouble(RedictModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_DOUBLE) goto loaderr; @@ -7270,10 +7270,10 @@ loaderr: /* In the context of the rdb_save method of a module data type, saves a float * value to the RDB file. The float can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadFloat(). */ -void RM_SaveFloat(RedisModuleIO *io, float value) { + * It is possible to load back the value with RedictModule_LoadFloat(). */ +void RM_SaveFloat(RedictModuleIO *io, float value) { if (io->error) return; - if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; + if (flushRedictModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ int retval = rdbSaveLen(io->rio, RDB_MODULE_OPCODE_FLOAT); if (retval == -1) goto saveerr; @@ -7289,8 +7289,8 @@ saveerr: } /* In the context of the rdb_save method of a module data type, loads back the - * float value saved by RedisModule_SaveFloat(). */ -float RM_LoadFloat(RedisModuleIO *io) { + * float value saved by RedictModule_SaveFloat(). */ +float RM_LoadFloat(RedictModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_FLOAT) goto loaderr; @@ -7306,8 +7306,8 @@ loaderr: /* In the context of the rdb_save method of a module data type, saves a long double * value to the RDB file. The double can be a valid number, a NaN or infinity. - * It is possible to load back the value with RedisModule_LoadLongDouble(). */ -void RM_SaveLongDouble(RedisModuleIO *io, long double value) { + * It is possible to load back the value with RedictModule_LoadLongDouble(). */ +void RM_SaveLongDouble(RedictModuleIO *io, long double value) { if (io->error) return; char buf[MAX_LONG_DOUBLE_CHARS]; /* Long double has different number of bits in different platforms, so we @@ -7317,8 +7317,8 @@ void RM_SaveLongDouble(RedisModuleIO *io, long double value) { } /* In the context of the rdb_save method of a module data type, loads back the - * long double value saved by RedisModule_SaveLongDouble(). */ -long double RM_LoadLongDouble(RedisModuleIO *io) { + * long double value saved by RedictModule_SaveLongDouble(). */ +long double RM_LoadLongDouble(RedictModuleIO *io) { if (io->error) return 0; long double value; size_t len; @@ -7337,7 +7337,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -7366,7 +7366,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { /* Add a new element to the digest. This function can be called multiple times * one element after the other, for all the elements that constitute a given * data structure. The function call must be followed by the call to - * `RedisModule_DigestEndSequence` eventually, when all the elements that are + * `RedictModule_DigestEndSequence` eventually, when all the elements that are * always in a given order are added. See the Redis Modules data types * documentation for more info. However this is a quick example that uses Redis * data types as an example. @@ -7401,20 +7401,20 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { * EndSequence(); * */ -void RM_DigestAddStringBuffer(RedisModuleDigest *md, const char *ele, size_t len) { +void RM_DigestAddStringBuffer(RedictModuleDigest *md, const char *ele, size_t len) { mixDigest(md->o,ele,len); } -/* Like `RedisModule_DigestAddStringBuffer()` but takes a `long long` as input +/* Like `RedictModule_DigestAddStringBuffer()` but takes a `long long` as input * that gets converted into a string before adding it to the digest. */ -void RM_DigestAddLongLong(RedisModuleDigest *md, long long ll) { +void RM_DigestAddLongLong(RedictModuleDigest *md, long long ll) { char buf[LONG_STR_SIZE]; size_t len = ll2string(buf,sizeof(buf),ll); mixDigest(md->o,buf,len); } -/* See the documentation for `RedisModule_DigestAddElement()`. */ -void RM_DigestEndSequence(RedisModuleDigest *md) { +/* See the documentation for `RedictModule_DigestAddElement()`. */ +void RM_DigestEndSequence(RedictModuleDigest *md) { xorDigest(md->x,md->o,sizeof(md->o)); memset(md->o,0,sizeof(md->o)); } @@ -7433,9 +7433,9 @@ void RM_DigestEndSequence(RedisModuleDigest *md) { * If this is NOT done, Redis will handle corrupted (or just truncated) serialized * data by producing an error message and terminating the process. */ -void *RM_LoadDataTypeFromStringEncver(const RedisModuleString *str, const moduleType *mt, int encver) { +void *RM_LoadDataTypeFromStringEncver(const RedictModuleString *str, const moduleType *mt, int encver) { rio payload; - RedisModuleIO io; + RedictModuleIO io; void *ret; rioInitWithBuffer(&payload, str->ptr); @@ -7455,20 +7455,20 @@ void *RM_LoadDataTypeFromStringEncver(const RedisModuleString *str, const module /* Similar to RM_LoadDataTypeFromStringEncver, original version of the API, kept * for backward compatibility. */ -void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) { +void *RM_LoadDataTypeFromString(const RedictModuleString *str, const moduleType *mt) { return RM_LoadDataTypeFromStringEncver(str, mt, 0); } /* Encode a module data type 'mt' value 'data' into serialized form, and return it - * as a newly allocated RedisModuleString. + * as a newly allocated RedictModuleString. * * This call basically reuses the 'rdb_save' callback which module data types * implement in order to allow a module to arbitrarily serialize/de-serialize * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. */ -RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, const moduleType *mt) { +RedictModuleString *RM_SaveDataTypeToString(RedictModuleCtx *ctx, void *data, const moduleType *mt) { rio payload; - RedisModuleIO io; + RedictModuleIO io; rioInitWithBuffer(&payload,sdsempty()); moduleInitIOContext(io,(moduleType *)mt,&payload,NULL,-1); @@ -7487,12 +7487,12 @@ RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, cons } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromDigest(RedisModuleDigest *dig) { +const RedictModuleString *RM_GetKeyNameFromDigest(RedictModuleDigest *dig) { return dig->key; } /* Returns the database id of the key currently being processed. */ -int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { +int RM_GetDbIdFromDigest(RedictModuleDigest *dig) { return dig->dbid; } /* -------------------------------------------------------------------------- @@ -7501,10 +7501,10 @@ int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { /* Emits a command into the AOF during the AOF rewriting process. This function * is only called in the context of the aof_rewrite method of data types exported - * by a module. The command works exactly like RedisModule_Call() in the way + * by a module. The command works exactly like RedictModule_Call() in the way * the parameters are passed, but it does not return anything as the error * handling is performed by Redis itself. */ -void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { +void RM_EmitAOF(RedictModuleIO *io, const char *cmdname, const char *fmt, ...) { if (io->error) return; struct redictCommand *cmd; robj **argv = NULL; @@ -7529,7 +7529,7 @@ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { if (argv == NULL) { serverLog(LL_WARNING, "Fatal: AOF method for module data type '%s' tried to " - "call RedisModule_EmitAOF() with wrong format specifiers '%s'", + "call RedictModule_EmitAOF() with wrong format specifiers '%s'", io->type->name, fmt); io->error = 1; errno = EINVAL; @@ -7554,9 +7554,9 @@ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { * ## IO context handling * -------------------------------------------------------------------------- */ -RedisModuleCtx *RM_GetContextFromIO(RedisModuleIO *io) { +RedictModuleCtx *RM_GetContextFromIO(RedictModuleIO *io) { if (io->ctx) return io->ctx; /* Can't have more than one... */ - io->ctx = zmalloc(sizeof(RedisModuleCtx)); + io->ctx = zmalloc(sizeof(RedictModuleCtx)); moduleCreateContext(io->ctx, io->type->module, REDISMODULE_CTX_NONE); return io->ctx; } @@ -7564,24 +7564,24 @@ RedisModuleCtx *RM_GetContextFromIO(RedisModuleIO *io) { /* Returns the name of the key currently being processed. * There is no guarantee that the key name is always available, so this may return NULL. */ -const RedisModuleString *RM_GetKeyNameFromIO(RedisModuleIO *io) { +const RedictModuleString *RM_GetKeyNameFromIO(RedictModuleIO *io) { return io->key; } -/* Returns a RedisModuleString with the name of the key from RedisModuleKey. */ -const RedisModuleString *RM_GetKeyNameFromModuleKey(RedisModuleKey *key) { +/* Returns a RedictModuleString with the name of the key from RedictModuleKey. */ +const RedictModuleString *RM_GetKeyNameFromModuleKey(RedictModuleKey *key) { return key ? key->key : NULL; } -/* Returns a database id of the key from RedisModuleKey. */ -int RM_GetDbIdFromModuleKey(RedisModuleKey *key) { +/* Returns a database id of the key from RedictModuleKey. */ +int RM_GetDbIdFromModuleKey(RedictModuleKey *key) { return key ? key->db->id : -1; } /* Returns the database id of the key currently being processed. * There is no guarantee that this info is always available, so this may return -1. */ -int RM_GetDbIdFromIO(RedisModuleIO *io) { +int RM_GetDbIdFromIO(RedictModuleIO *io) { return io->dbid; } @@ -7595,7 +7595,7 @@ int RM_GetDbIdFromIO(RedisModuleIO *io) { * RM_LogIOError() * */ -void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va_list ap) { +void moduleLogRaw(RedictModule *module, const char *levelstr, const char *fmt, va_list ap) { char msg[LOG_MAX_LEN]; size_t name_len; int level; @@ -7631,7 +7631,7 @@ void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va * caller for instance threads or callbacks, in which case a generic "module" * will be used instead of the module name. */ -void RM_Log(RedisModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { +void RM_Log(RedictModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(ctx? ctx->module: NULL,levelstr,fmt,ap); @@ -7643,7 +7643,7 @@ void RM_Log(RedisModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { * This function should be used when a callback is returning a critical * error to the caller since cannot load or save the data for some * critical reason. */ -void RM_LogIOError(RedisModuleIO *io, const char *levelstr, const char *fmt, ...) { +void RM_LogIOError(RedictModuleIO *io, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(io->type->module,levelstr,fmt,ap); @@ -7652,7 +7652,7 @@ void RM_LogIOError(RedisModuleIO *io, const char *levelstr, const char *fmt, ... /* Redis-like assert function. * - * The macro `RedisModule_Assert(expression)` is recommended, rather than + * The macro `RedictModule_Assert(expression)` is recommended, rather than * calling this function directly. * * A failed assertion will shut down the server and produce logging information @@ -7679,7 +7679,7 @@ void RM_LatencyAddSample(const char *event, mstime_t latency) { /* Returns 1 if the client already in the moduleUnblocked list, 0 otherwise. */ int isModuleClientUnblocked(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; return bc->unblocked == 1; } @@ -7694,17 +7694,17 @@ int isModuleClientUnblocked(client *c) { * is a pending threaded operation involving the blocked client, we'll know * that the client no longer exists and no reply callback should be called. * - * The structure RedisModuleBlockedClient will be always deallocated when + * The structure RedictModuleBlockedClient will be always deallocated when * running the list of clients blocked by a module that need to be unblocked. */ void unblockClientFromModule(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Call the disconnection callback if any. Note that * bc->disconnect_callback is set to NULL if the client gets disconnected * by the module itself or because of a timeout, so the callback will NOT * get called if this is not an actual disconnection event. */ if (bc->disconnect_callback) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_NONE); ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; @@ -7717,7 +7717,7 @@ void unblockClientFromModule(client *c) { * not implemented (or it was, but RM_UnblockClient was not called from * within it, as it should). * We must call moduleUnblockClient in order to free privdata and - * RedisModuleBlockedClient. + * RedictModuleBlockedClient. * * Note that we only do that for clients that are blocked on keys, for which * the contract is that the module should not call RM_UnblockClient under @@ -7753,17 +7753,17 @@ void unblockClientFromModule(client *c) { * reply callback the privdata that is set here while blocking. * */ -RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleAuthCallback auth_reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, +RedictModuleBlockedClient *moduleBlockClient(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, + RedictModuleAuthCallback auth_reply_callback, + RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), + long long timeout_ms, RedictModuleString **keys, int numkeys, void *privdata, int flags) { client *c = ctx->client; int islua = scriptIsRunning(); int ismulti = server.in_exec; - c->bstate.module_blocked_handle = zmalloc(sizeof(RedisModuleBlockedClient)); - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + c->bstate.module_blocked_handle = zmalloc(sizeof(RedictModuleBlockedClient)); + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; ctx->module->blocked_clients++; /* We need to handle the invalid operation of calling modules blocking @@ -7848,43 +7848,43 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF * * The following is an example of how non-blocking module based authentication can be used: * - * int auth_cb(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *password, RedisModuleString **err) { - * const char *user = RedisModule_StringPtrLen(username, NULL); - * const char *pwd = RedisModule_StringPtrLen(password, NULL); + * int auth_cb(RedictModuleCtx *ctx, RedictModuleString *username, RedictModuleString *password, RedictModuleString **err) { + * const char *user = RedictModule_StringPtrLen(username, NULL); + * const char *pwd = RedictModule_StringPtrLen(password, NULL); * if (!strcmp(user,"foo") && !strcmp(pwd,"valid_password")) { - * RedisModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); + * RedictModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); * return REDISMODULE_AUTH_HANDLED; * } * * else if (!strcmp(user,"foo") && !strcmp(pwd,"wrong_password")) { - * RedisModuleString *log = RedisModule_CreateString(ctx, "Module Auth", 11); - * RedisModule_ACLAddLogEntryByUserName(ctx, username, log, REDISMODULE_ACL_LOG_AUTH); - * RedisModule_FreeString(ctx, log); + * RedictModuleString *log = RedictModule_CreateString(ctx, "Module Auth", 11); + * RedictModule_ACLAddLogEntryByUserName(ctx, username, log, REDISMODULE_ACL_LOG_AUTH); + * RedictModule_FreeString(ctx, log); * const char *err_msg = "Auth denied by Misc Module."; - * *err = RedisModule_CreateString(ctx, err_msg, strlen(err_msg)); + * *err = RedictModule_CreateString(ctx, err_msg, strlen(err_msg)); * return REDISMODULE_AUTH_HANDLED; * } * return REDISMODULE_AUTH_NOT_HANDLED; * } * - * int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - * if (RedisModule_Init(ctx,"authmodule",1,REDISMODULE_APIVER_1)== REDISMODULE_ERR) + * int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + * if (RedictModule_Init(ctx,"authmodule",1,REDISMODULE_APIVER_1)== REDISMODULE_ERR) * return REDISMODULE_ERR; - * RedisModule_RegisterAuthCallback(ctx, auth_cb); + * RedictModule_RegisterAuthCallback(ctx, auth_cb); * return REDISMODULE_OK; * } */ -void RM_RegisterAuthCallback(RedisModuleCtx *ctx, RedisModuleAuthCallback cb) { - RedisModuleAuthCtx *auth_ctx = zmalloc(sizeof(RedisModuleAuthCtx)); +void RM_RegisterAuthCallback(RedictModuleCtx *ctx, RedictModuleAuthCallback cb) { + RedictModuleAuthCtx *auth_ctx = zmalloc(sizeof(RedictModuleAuthCtx)); auth_ctx->module = ctx->module; auth_ctx->auth_cb = cb; listAddNodeHead(moduleAuthCallbacks, auth_ctx); } /* Helper function to invoke the free private data callback of a Module blocked client. */ -void moduleInvokeFreePrivDataCallback(client *c, RedisModuleBlockedClient *bc) { +void moduleInvokeFreePrivDataCallback(client *c, RedictModuleBlockedClient *bc) { if (bc->privdata && bc->free_privdata) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; int ctx_flags = c == NULL ? REDISMODULE_CTX_BLOCKED_DISCONNECTED : REDISMODULE_CTX_NONE; moduleCreateContext(&ctx, bc->module, ctx_flags); ctx.blocked_privdata = bc->privdata; @@ -7895,12 +7895,12 @@ void moduleInvokeFreePrivDataCallback(client *c, RedisModuleBlockedClient *bc) { } /* Unregisters all the module auth callbacks that have been registered by this Module. */ -void moduleUnregisterAuthCBs(RedisModule *module) { +void moduleUnregisterAuthCBs(RedictModule *module) { listIter li; listNode *ln; listRewind(moduleAuthCallbacks, &li); while ((ln = listNext(&li))) { - RedisModuleAuthCtx *ctx = listNodeValue(ln); + RedictModuleAuthCtx *ctx = listNodeValue(ln); if (ctx->module == module) { listDelNode(moduleAuthCallbacks, ln); zfree(ctx); @@ -7912,7 +7912,7 @@ void moduleUnregisterAuthCBs(RedisModule *module) { * Returns the result of the module auth callback. */ int attemptNextAuthCb(client *c, robj *username, robj *password, robj **err) { int handle_next_callback = c->module_auth_ctx == NULL; - RedisModuleAuthCtx *cur_auth_ctx = NULL; + RedictModuleAuthCtx *cur_auth_ctx = NULL; listNode *ln; listIter li; listRewind(moduleAuthCallbacks, &li); @@ -7926,7 +7926,7 @@ int attemptNextAuthCb(client *c, robj *username, robj *password, robj **err) { } /* Remove the module auth complete flag before we attempt the next cb. */ c->flags &= ~CLIENT_MODULE_AUTH_HAS_RESULT; - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, cur_auth_ctx->module, REDISMODULE_CTX_NONE); ctx.client = c; *err = NULL; @@ -7947,10 +7947,10 @@ int attemptNextAuthCb(client *c, robj *username, robj *password, robj **err) { int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, robj **err) { int result = REDISMODULE_AUTH_NOT_HANDLED; if (!c->module_blocked_client) return result; - RedisModuleBlockedClient *bc = (RedisModuleBlockedClient *) c->module_blocked_client; + RedictModuleBlockedClient *bc = (RedictModuleBlockedClient *) c->module_blocked_client; bc->client = c; if (bc->auth_reply_cb) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; @@ -7968,7 +7968,7 @@ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, r } /* Helper function to attempt Module based authentication through module auth callbacks. - * Here, the Module is expected to authenticate the client using the RedisModule APIs and to add ACL + * Here, the Module is expected to authenticate the client using the RedictModule APIs and to add ACL * logs in case of errors. * Returns one of the following codes: * AUTH_OK - Indicates that a module handled and authenticated the client. @@ -8009,14 +8009,14 @@ int checkModuleAuthentication(client *c, robj *username, robj *password, robj ** * This function returns 1 if client was served (and should be unblocked) */ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { int served = 0; - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Protect against re-processing: don't serve clients that are already * in the unblocking list for any reason (including RM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return 0; - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); ctx.blocked_ready_key = key; ctx.blocked_privdata = bc->privdata; @@ -8030,30 +8030,30 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { /* Block a client in the context of a blocking command, returning a handle * which will be used, later, in order to unblock the client with a call to - * RedisModule_UnblockClient(). The arguments specify callback functions + * RedictModule_UnblockClient(). The arguments specify callback functions * and a timeout after which the client is unblocked. * * The callbacks are called in the following contexts: * - * reply_callback: called after a successful RedisModule_UnblockClient() + * reply_callback: called after a successful RedictModule_UnblockClient() * call in order to reply to the client and unblock it. * * timeout_callback: called when the timeout is reached or if `CLIENT UNBLOCK` * is invoked, in order to send an error to the client. * * free_privdata: called in order to free the private data that is passed - * by RedisModule_UnblockClient() call. + * by RedictModule_UnblockClient() call. * - * Note: RedisModule_UnblockClient should be called for every blocked client, + * Note: RedictModule_UnblockClient should be called for every blocked client, * even if client was killed, timed-out or disconnected. Failing to do so * will result in memory leaks. * - * There are some cases where RedisModule_BlockClient() cannot be used: + * There are some cases where RedictModule_BlockClient() cannot be used: * * 1. If the client is a Lua script. * 2. If the client is executing a MULTI block. * - * In these cases, a call to RedisModule_BlockClient() will **not** block the + * In these cases, a call to RedictModule_BlockClient() will **not** block the * client, but instead produce a specific error reply. * * A module that registers a timeout_callback function can also be unblocked @@ -8067,8 +8067,8 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { * use RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd() one, * or multiple times within the blocking command background work. */ -RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), +RedictModuleBlockedClient *RM_BlockClient(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, + RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), long long timeout_ms) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, NULL,0,NULL,0); } @@ -8077,13 +8077,13 @@ RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc * progress on the client, the API returns NULL. Otherwise, the client is blocked and the RM_BlockedClient * is returned similar to the RM_BlockClient API. * Note: Only use this API from the context of a module auth callback. */ -RedisModuleBlockedClient *RM_BlockClientOnAuth(RedisModuleCtx *ctx, RedisModuleAuthCallback reply_callback, - void (*free_privdata)(RedisModuleCtx*,void*)) { +RedictModuleBlockedClient *RM_BlockClientOnAuth(RedictModuleCtx *ctx, RedictModuleAuthCallback reply_callback, + void (*free_privdata)(RedictModuleCtx*,void*)) { if (!clientHasModuleAuthInProgress(ctx->client)) { addReplyError(ctx->client, "Module blocking client on auth when not currently undergoing module authentication"); return NULL; } - RedisModuleBlockedClient *bc = moduleBlockClient(ctx,NULL,reply_callback,NULL,free_privdata,0, NULL,0,NULL,0); + RedictModuleBlockedClient *bc = moduleBlockClient(ctx,NULL,reply_callback,NULL,free_privdata,0, NULL,0,NULL,0); if (ctx->client->flags & CLIENT_BLOCKED) { ctx->client->flags |= CLIENT_PENDING_COMMAND; } @@ -8091,16 +8091,16 @@ RedisModuleBlockedClient *RM_BlockClientOnAuth(RedisModuleCtx *ctx, RedisModuleA } /* Get the private data that was previusely set on a blocked client */ -void *RM_BlockClientGetPrivateData(RedisModuleBlockedClient *blocked_client) { +void *RM_BlockClientGetPrivateData(RedictModuleBlockedClient *blocked_client) { return blocked_client->privdata; } /* Set private data on a blocked client */ -void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void *private_data) { +void RM_BlockClientSetPrivateData(RedictModuleBlockedClient *blocked_client, void *private_data) { blocked_client->privdata = private_data; } -/* This call is similar to RedisModule_BlockClient(), however in this case we +/* This call is similar to RedictModule_BlockClient(), however in this case we * don't just block the client, but also ask Redis to unblock it automatically * once certain keys become "ready", that is, contain more data. * @@ -8118,31 +8118,31 @@ void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void * on a list key, an RPUSH command may unblock our client and so forth. * 2. If you are implementing your native data type, or if you want to add new * unblocking conditions in addition to "1", you can call the modules API - * RedisModule_SignalKeyAsReady(). + * RedictModule_SignalKeyAsReady(). * * Anyway we can't be sure if the client should be unblocked just because the * key is signaled as ready: for instance a successive operation may change the * key, or a client in queue before this one can be served, modifying the key * as well and making it empty again. So when a client is blocked with - * RedisModule_BlockClientOnKeys() the reply callback is not called after + * RedictModule_BlockClientOnKeys() the reply callback is not called after * RM_UnblockClient() is called, but every time a key is signaled as ready: * if the reply callback can serve the client, it returns REDISMODULE_OK * and the client is unblocked, otherwise it will return REDISMODULE_ERR * and we'll try again later. * * The reply callback can access the key that was signaled as ready by - * calling the API RedisModule_GetBlockedClientReadyKey(), that returns - * just the string name of the key as a RedisModuleString object. + * calling the API RedictModule_GetBlockedClientReadyKey(), that returns + * just the string name of the key as a RedictModuleString object. * * Thanks to this system we can setup complex blocking scenarios, like * unblocking a client only if a list contains at least 5 items or other * more fancy logics. * - * Note that another difference with RedisModule_BlockClient(), is that here + * Note that another difference with RedictModule_BlockClient(), is that here * we pass the private data directly when blocking the client: it will * be accessible later in the reply callback. Normally when blocking with - * RedisModule_BlockClient() the private data to reply to the client is - * passed when calling RedisModule_UnblockClient() but here the unblocking + * RedictModule_BlockClient() the private data to reply to the client is + * passed when calling RedictModule_UnblockClient() but here the unblocking * is performed by Redis itself, so we need to have some private data before * hand. The private data is used to store any information about the specific * unblocking operation that you are implementing. Such information will be @@ -8151,44 +8151,44 @@ void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void * However the reply callback will be able to access the argument vector of * the command, so the private data is often not needed. * - * Note: Under normal circumstances RedisModule_UnblockClient should not be + * Note: Under normal circumstances RedictModule_UnblockClient should not be * called for clients that are blocked on keys (Either the key will * become ready or a timeout will occur). If for some reason you do want - * to call RedisModule_UnblockClient it is possible: Client will be + * to call RedictModule_UnblockClient it is possible: Client will be * handled as if it were timed-out (You must implement the timeout * callback in that case). */ -RedisModuleBlockedClient *RM_BlockClientOnKeys(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) { +RedictModuleBlockedClient *RM_BlockClientOnKeys(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, + RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), + long long timeout_ms, RedictModuleString **keys, int numkeys, void *privdata) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, keys,numkeys,privdata,0); } -/* Same as RedisModule_BlockClientOnKeys, but can take REDISMODULE_BLOCK_* flags +/* Same as RedictModule_BlockClientOnKeys, but can take REDISMODULE_BLOCK_* flags * Can be either REDISMODULE_BLOCK_UNBLOCK_DEFAULT, which means default behavior (same - * as calling RedisModule_BlockClientOnKeys) + * as calling RedictModule_BlockClientOnKeys) * * The flags is a bit mask of these: * * - `REDISMODULE_BLOCK_UNBLOCK_DELETED`: The clients should to be awakened in case any of `keys` are deleted. * Mostly useful for commands that require the key to exist (like XREADGROUP) */ -RedisModuleBlockedClient *RM_BlockClientOnKeysWithFlags(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, - RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), - long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, +RedictModuleBlockedClient *RM_BlockClientOnKeysWithFlags(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, + RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), + long long timeout_ms, RedictModuleString **keys, int numkeys, void *privdata, int flags) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, keys,numkeys,privdata,flags); } /* This function is used in order to potentially unblock a client blocked - * on keys with RedisModule_BlockClientOnKeys(). When this function is called, + * on keys with RedictModule_BlockClientOnKeys(). When this function is called, * all the clients blocked for this key will get their reply_callback called. */ -void RM_SignalKeyAsReady(RedisModuleCtx *ctx, RedisModuleString *key) { +void RM_SignalKeyAsReady(RedictModuleCtx *ctx, RedictModuleString *key) { signalKeyAsReady(ctx->client->db, key, OBJ_MODULE); } /* Implements RM_UnblockClient() and moduleUnblockClient(). */ -int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { +int moduleUnblockClientByHandle(RedictModuleBlockedClient *bc, void *privdata) { pthread_mutex_lock(&moduleUnblockedClientsMutex); if (!bc->blocked_on_keys) bc->privdata = privdata; bc->unblocked = 1; @@ -8205,18 +8205,18 @@ int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { /* This API is used by the Redis core to unblock a client that was blocked * by a module. */ void moduleUnblockClient(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; moduleUnblockClientByHandle(bc,NULL); } /* Return true if the client 'c' was blocked by a module using * RM_BlockClientOnKeys(). */ int moduleClientIsBlockedOnKeys(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; return bc->blocked_on_keys; } -/* Unblock a client blocked by `RedisModule_BlockedClient`. This will trigger +/* Unblock a client blocked by `RedictModule_BlockedClient`. This will trigger * the reply callbacks to be called in order to reply to the client. * The 'privdata' argument will be accessible by the reply callback, so * the caller of this function can pass any value that is needed in order to @@ -8229,13 +8229,13 @@ int moduleClientIsBlockedOnKeys(client *c) { * Note 1: this function can be called from threads spawned by the module. * * Note 2: when we unblock a client that is blocked for keys using the API - * RedisModule_BlockClientOnKeys(), the privdata argument here is not used. + * RedictModule_BlockClientOnKeys(), the privdata argument here is not used. * Unblocking a client that was blocked for keys using this API will still * require the client to get some reply, so the function will use the * "timeout" handler in order to do so (The privdata provided in - * RedisModule_BlockClientOnKeys() is accessible from the timeout + * RedictModule_BlockClientOnKeys() is accessible from the timeout * callback via RM_GetBlockedClientPrivateData). */ -int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) { +int RM_UnblockClient(RedictModuleBlockedClient *bc, void *privdata) { if (bc->blocked_on_keys) { /* In theory the user should always pass the timeout handler as an * argument, but better to be safe than sorry. */ @@ -8249,7 +8249,7 @@ int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) { /* Abort a blocked client blocking operation: the client will be unblocked * without firing any callback. */ -int RM_AbortBlock(RedisModuleBlockedClient *bc) { +int RM_AbortBlock(RedictModuleBlockedClient *bc) { bc->reply_callback = NULL; bc->disconnect_callback = NULL; bc->auth_reply_cb = NULL; @@ -8257,10 +8257,10 @@ int RM_AbortBlock(RedisModuleBlockedClient *bc) { } /* Set a callback that will be called if a blocked client disconnects - * before the module has a chance to call RedisModule_UnblockClient() + * before the module has a chance to call RedictModule_UnblockClient() * * Usually what you want to do there, is to cleanup your module state - * so that you can call RedisModule_UnblockClient() safely, otherwise + * so that you can call RedictModule_UnblockClient() safely, otherwise * the client will remain blocked forever if the timeout is large. * * Notes: @@ -8272,7 +8272,7 @@ int RM_AbortBlock(RedisModuleBlockedClient *bc) { * a timeout. In such a case, the client is unblocked automatically * and the timeout callback is called. */ -void RM_SetDisconnectCallback(RedisModuleBlockedClient *bc, RedisModuleDisconnectFunc callback) { +void RM_SetDisconnectCallback(RedictModuleBlockedClient *bc, RedictModuleDisconnectFunc callback) { bc->disconnect_callback = callback; } @@ -8282,11 +8282,11 @@ void RM_SetDisconnectCallback(RedisModuleBlockedClient *bc, RedisModuleDisconnec * Clients end into this list because of calls to RM_UnblockClient(), * however it is possible that while the module was doing work for the * blocked client, it was terminated by Redis (for timeout or other reasons). - * When this happens the RedisModuleBlockedClient structure in the queue + * When this happens the RedictModuleBlockedClient structure in the queue * will have the 'client' field set to NULL. */ void moduleHandleBlockedClients(void) { listNode *ln; - RedisModuleBlockedClient *bc; + RedictModuleBlockedClient *bc; pthread_mutex_lock(&moduleUnblockedClientsMutex); while (listLength(moduleUnblockedClients)) { @@ -8307,7 +8307,7 @@ void moduleHandleBlockedClients(void) { long long prev_error_replies = server.stat_total_error_replies; uint64_t reply_us = 0; if (c && !bc->blocked_on_keys && bc->reply_callback) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; @@ -8389,7 +8389,7 @@ int moduleBlockedClientMayTimeout(client *c) { if (c->bstate.btype != BLOCKED_MODULE) return 1; - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; return (bc && bc->timeout_callback != NULL); } @@ -8405,14 +8405,14 @@ int moduleBlockedClientMayTimeout(client *c) { * of the client synchronously. This ensures that we can reply to the client before * resetClient() is called. */ void moduleBlockedClientTimedOut(client *c, int from_module) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + RedictModuleBlockedClient *bc = c->bstate.module_blocked_handle; /* Protect against re-processing: don't serve clients that are already * in the unblocking list for any reason (including RM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return; - RedisModuleCtx ctx; + RedictModuleCtx ctx; int flags = REDISMODULE_CTX_BLOCKED_TIMEOUT; if (from_module) flags |= REDISMODULE_CTX_THREAD_SAFE; moduleCreateContext(&ctx, bc->module, flags); @@ -8443,24 +8443,24 @@ void moduleBlockedClientTimedOut(client *c, int from_module) { /* Return non-zero if a module command was called in order to fill the * reply for a blocked client. */ -int RM_IsBlockedReplyRequest(RedisModuleCtx *ctx) { +int RM_IsBlockedReplyRequest(RedictModuleCtx *ctx) { return (ctx->flags & REDISMODULE_CTX_BLOCKED_REPLY) != 0; } /* Return non-zero if a module command was called in order to fill the * reply for a blocked client that timed out. */ -int RM_IsBlockedTimeoutRequest(RedisModuleCtx *ctx) { +int RM_IsBlockedTimeoutRequest(RedictModuleCtx *ctx) { return (ctx->flags & REDISMODULE_CTX_BLOCKED_TIMEOUT) != 0; } -/* Get the private data set by RedisModule_UnblockClient() */ -void *RM_GetBlockedClientPrivateData(RedisModuleCtx *ctx) { +/* Get the private data set by RedictModule_UnblockClient() */ +void *RM_GetBlockedClientPrivateData(RedictModuleCtx *ctx) { return ctx->blocked_privdata; } /* Get the key that is ready when the reply callback is called in the context - * of a client blocked by RedisModule_BlockClientOnKeys(). */ -RedisModuleString *RM_GetBlockedClientReadyKey(RedisModuleCtx *ctx) { + * of a client blocked by RedictModule_BlockClientOnKeys(). */ +RedictModuleString *RM_GetBlockedClientReadyKey(RedictModuleCtx *ctx) { return ctx->blocked_ready_key; } @@ -8468,14 +8468,14 @@ RedisModuleString *RM_GetBlockedClientReadyKey(RedisModuleCtx *ctx) { * This is useful in the reply and timeout callbacks of blocked clients, * before sometimes the module has the blocked client handle references * around, and wants to cleanup it. */ -RedisModuleBlockedClient *RM_GetBlockedClientHandle(RedisModuleCtx *ctx) { +RedictModuleBlockedClient *RM_GetBlockedClientHandle(RedictModuleCtx *ctx) { return ctx->blocked_client; } /* Return true if when the free callback of a blocked client is called, * the reason for the client to be unblocked is that it disconnected * while it was blocked. */ -int RM_BlockedClientDisconnected(RedisModuleCtx *ctx) { +int RM_BlockedClientDisconnected(RedictModuleCtx *ctx) { return (ctx->flags & REDISMODULE_CTX_BLOCKED_DISCONNECTED) != 0; } @@ -8486,26 +8486,26 @@ int RM_BlockedClientDisconnected(RedisModuleCtx *ctx) { /* Return a context which can be used inside threads to make Redis context * calls with certain modules APIs. If 'bc' is not NULL then the module will * be bound to a blocked client, and it will be possible to use the - * `RedisModule_Reply*` family of functions to accumulate a reply for when the + * `RedictModule_Reply*` family of functions to accumulate a reply for when the * client will be unblocked. Otherwise the thread safe context will be * detached by a specific client. * * To call non-reply APIs, the thread safe context must be prepared with: * - * RedisModule_ThreadSafeContextLock(ctx); + * RedictModule_ThreadSafeContextLock(ctx); * ... make your call here ... - * RedisModule_ThreadSafeContextUnlock(ctx); + * RedictModule_ThreadSafeContextUnlock(ctx); * - * This is not needed when using `RedisModule_Reply*` functions, assuming + * This is not needed when using `RedictModule_Reply*` functions, assuming * that a blocked client was used when the context was created, otherwise - * no RedisModule_Reply* call should be made at all. + * no RedictModule_Reply* call should be made at all. * * NOTE: If you're creating a detached thread safe context (bc is NULL), * consider using `RM_GetDetachedThreadSafeContext` which will also retain * the module ID and thus be more useful for logging. */ -RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { - RedisModuleCtx *ctx = zmalloc(sizeof(*ctx)); - RedisModule *module = bc ? bc->module : NULL; +RedictModuleCtx *RM_GetThreadSafeContext(RedictModuleBlockedClient *bc) { + RedictModuleCtx *ctx = zmalloc(sizeof(*ctx)); + RedictModule *module = bc ? bc->module : NULL; int flags = REDISMODULE_CTX_THREAD_SAFE; /* Creating a new client object is costly. To avoid that, we have an @@ -8541,8 +8541,8 @@ RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { * * This is useful for modules that wish to hold a global context over * a long term, for purposes such as logging. */ -RedisModuleCtx *RM_GetDetachedThreadSafeContext(RedisModuleCtx *ctx) { - RedisModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx)); +RedictModuleCtx *RM_GetDetachedThreadSafeContext(RedictModuleCtx *ctx) { + RedictModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx)); /* We create a new client object for the detached context. * See RM_GetThreadSafeContext() for more information */ moduleCreateContext(new_ctx, ctx->module, @@ -8551,7 +8551,7 @@ RedisModuleCtx *RM_GetDetachedThreadSafeContext(RedisModuleCtx *ctx) { } /* Release a thread safe context. */ -void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) { +void RM_FreeThreadSafeContext(RedictModuleCtx *ctx) { moduleFreeContext(ctx); zfree(ctx); } @@ -8566,9 +8566,9 @@ void moduleGILAfterLock(void) { } /* Acquire the server lock before executing a thread safe API call. - * This is not needed for `RedisModule_Reply*` calls when there is + * This is not needed for `RedictModule_Reply*` calls when there is * a blocked client connected to the thread safe context. */ -void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) { +void RM_ThreadSafeContextLock(RedictModuleCtx *ctx) { UNUSED(ctx); moduleAcquireGIL(); moduleGILAfterLock(); @@ -8580,7 +8580,7 @@ void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) { * If successful (lock acquired) REDISMODULE_OK is returned, * otherwise REDISMODULE_ERR is returned and errno is set * accordingly. */ -int RM_ThreadSafeContextTryLock(RedisModuleCtx *ctx) { +int RM_ThreadSafeContextTryLock(RedictModuleCtx *ctx) { UNUSED(ctx); int res = moduleTryAcquireGIL(); @@ -8605,7 +8605,7 @@ void moduleGILBeforeUnlock(void) { } /* Release the server lock after a thread safe API call was executed. */ -void RM_ThreadSafeContextUnlock(RedisModuleCtx *ctx) { +void RM_ThreadSafeContextUnlock(RedictModuleCtx *ctx) { UNUSED(ctx); moduleGILBeforeUnlock(); moduleReleaseGIL(); @@ -8636,7 +8636,7 @@ void moduleReleaseGIL(void) { * etc), and the subscriber callback receives only events that match a specific * mask of event types. * - * When subscribing to notifications with RedisModule_SubscribeToKeyspaceEvents + * When subscribing to notifications with RedictModule_SubscribeToKeyspaceEvents * the module must provide an event type-mask, denoting the events the subscriber * is interested in. This can be an ORed mask of any of the following flags: * @@ -8669,9 +8669,9 @@ void moduleReleaseGIL(void) { * * The subscriber signature is: * - * int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, + * int (*RedictModuleNotificationFunc) (RedictModuleCtx *ctx, int type, * const char *event, - * RedisModuleString *key); + * RedictModuleString *key); * * `type` is the event type bit, that must match the mask given at registration * time. The event string is the actual command being executed, and key is the @@ -8696,8 +8696,8 @@ void moduleReleaseGIL(void) { * * See https://redis.io/topics/notifications for more information. */ -int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc callback) { - RedisModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); +int RM_SubscribeToKeyspaceEvents(RedictModuleCtx *ctx, int types, RedictModuleNotificationFunc callback) { + RedictModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); sub->module = ctx->module; sub->event_mask = types; sub->notify_callback = callback; @@ -8716,10 +8716,10 @@ void firePostExecutionUnitJobs(void) { enterExecutionUnit(0, 0); while (listLength(modulePostExecUnitJobs) > 0) { listNode *ln = listFirst(modulePostExecUnitJobs); - RedisModulePostExecUnitJob *job = listNodeValue(ln); + RedictModulePostExecUnitJob *job = listNodeValue(ln); listDelNode(modulePostExecUnitJobs, ln); - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, job->module, REDISMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, job->dbid); @@ -8749,11 +8749,11 @@ void firePostExecutionUnitJobs(void) { * * Return REDISMODULE_OK on success and REDISMODULE_ERR if was called while loading data from disk (AOF or RDB) or * if the instance is a readonly replica. */ -int RM_AddPostNotificationJob(RedisModuleCtx *ctx, RedisModulePostNotificationJobFunc callback, void *privdata, void (*free_privdata)(void*)) { +int RM_AddPostNotificationJob(RedictModuleCtx *ctx, RedictModulePostNotificationJobFunc callback, void *privdata, void (*free_privdata)(void*)) { if (server.loading|| (server.masterhost && server.repl_slave_ro)) { return REDISMODULE_ERR; } - RedisModulePostExecUnitJob *job = zmalloc(sizeof(*job)); + RedictModulePostExecUnitJob *job = zmalloc(sizeof(*job)); job->module = ctx->module; job->callback = callback; job->pd = privdata; @@ -8765,13 +8765,13 @@ int RM_AddPostNotificationJob(RedisModuleCtx *ctx, RedisModulePostNotificationJo } /* Get the configured bitmap of notify-keyspace-events (Could be used - * for additional filtering in RedisModuleNotificationFunc) */ + * for additional filtering in RedictModuleNotificationFunc) */ int RM_GetNotifyKeyspaceEvents(void) { return server.notify_keyspace_events; } /* Expose notifyKeyspaceEvent to modules */ -int RM_NotifyKeyspaceEvent(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) { +int RM_NotifyKeyspaceEvent(RedictModuleCtx *ctx, int type, const char *event, RedictModuleString *key) { if (!ctx || !ctx->client) return REDISMODULE_ERR; notifyKeyspaceEvent(type, (char *)event, key, ctx->client->db->id); @@ -8787,7 +8787,7 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) /* Ugly hack to handle modules which use write commands from within * notify_callback, which they should NOT do! - * Modules should use RedisModules_AddPostNotificationJob instead. + * Modules should use RedictModules_AddPostNotificationJob instead. * * Anyway, we want any propagated commands from within notify_callback * to be propagated inside a MULTI/EXEC together with the original @@ -8812,12 +8812,12 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) type &= ~(NOTIFY_KEYEVENT | NOTIFY_KEYSPACE); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + RedictModuleKeyspaceSubscriber *sub = ln->value; /* Only notify subscribers on events matching the registration, * and avoid subscribers triggering themselves */ if ((sub->event_mask & type) && (sub->active == 0 || (sub->module->options & REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS))) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, sub->module, REDISMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, dbid); @@ -8838,12 +8838,12 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) } /* Unsubscribe any notification subscribers this module has upon unloading */ -void moduleUnsubscribeNotifications(RedisModule *module) { +void moduleUnsubscribeNotifications(RedictModule *module) { listIter li; listNode *ln; listRewind(moduleKeyspaceSubscribers,&li); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + RedictModuleKeyspaceSubscriber *sub = ln->value; if (sub->module == module) { listDelNode(moduleKeyspaceSubscribers, ln); zfree(sub); @@ -8856,15 +8856,15 @@ void moduleUnsubscribeNotifications(RedisModule *module) { * -------------------------------------------------------------------------- */ /* The Cluster message callback function pointer type. */ -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*RedictModuleClusterMessageReceiver)(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); /* This structure identifies a registered caller: it must match a given module * ID, for a given message type. The callback function is just the function * that was registered as receiver. */ typedef struct moduleClusterReceiver { uint64_t module_id; - RedisModuleClusterMessageReceiver callback; - struct RedisModule *module; + RedictModuleClusterMessageReceiver callback; + struct RedictModule *module; struct moduleClusterReceiver *next; } moduleClusterReceiver; @@ -8884,7 +8884,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8 moduleClusterReceiver *r = clusterReceivers[type]; while(r) { if (r->module_id == module_id) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, r->module, REDISMODULE_CTX_TEMP_CLIENT); r->callback(&ctx,sender_id,type,payload,len); moduleFreeContext(&ctx); @@ -8899,7 +8899,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8 * with the one provided, otherwise if the callback is set to NULL and there * is already a callback for this function, the callback is unregistered * (so this API call is also used in order to delete the receiver). */ -void RM_RegisterClusterMessageReceiver(RedisModuleCtx *ctx, uint8_t type, RedisModuleClusterMessageReceiver callback) { +void RM_RegisterClusterMessageReceiver(RedictModuleCtx *ctx, uint8_t type, RedictModuleClusterMessageReceiver callback) { if (!server.cluster_enabled) return; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); @@ -8943,7 +8943,7 @@ void RM_RegisterClusterMessageReceiver(RedisModuleCtx *ctx, uint8_t type, RedisM * The function returns REDISMODULE_OK if the message was successfully sent, * otherwise if the node is not connected or such node ID does not map to any * known cluster node, REDISMODULE_ERR is returned. */ -int RM_SendClusterMessage(RedisModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) { +int RM_SendClusterMessage(RedictModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) { if (!server.cluster_enabled) return REDISMODULE_ERR; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); if (clusterSendModuleMessageToTarget(target_id,module_id,type,msg,len) == C_OK) @@ -8958,30 +8958,30 @@ int RM_SendClusterMessage(RedisModuleCtx *ctx, const char *target_id, uint8_t ty * However if this function is called by a module not running an a Redis * instance with Redis Cluster enabled, NULL is returned instead. * - * The IDs returned can be used with RedisModule_GetClusterNodeInfo() in order + * The IDs returned can be used with RedictModule_GetClusterNodeInfo() in order * to get more information about single node. * * The array returned by this function must be freed using the function - * RedisModule_FreeClusterNodesList(). + * RedictModule_FreeClusterNodesList(). * * Example: * * size_t count, j; - * char **ids = RedisModule_GetClusterNodesList(ctx,&count); + * char **ids = RedictModule_GetClusterNodesList(ctx,&count); * for (j = 0; j < count; j++) { - * RedisModule_Log(ctx,"notice","Node %.*s", + * RedictModule_Log(ctx,"notice","Node %.*s", * REDISMODULE_NODE_ID_LEN,ids[j]); * } - * RedisModule_FreeClusterNodesList(ids); + * RedictModule_FreeClusterNodesList(ids); */ -char **RM_GetClusterNodesList(RedisModuleCtx *ctx, size_t *numnodes) { +char **RM_GetClusterNodesList(RedictModuleCtx *ctx, size_t *numnodes) { UNUSED(ctx); if (!server.cluster_enabled) return NULL; return getClusterNodesList(numnodes); } -/* Free the node list obtained with RedisModule_GetClusterNodesList. */ +/* Free the node list obtained with RedictModule_GetClusterNodesList. */ void RM_FreeClusterNodesList(char **ids) { if (ids == NULL) return; for (int j = 0; ids[j]; j++) zfree(ids[j]); @@ -9024,7 +9024,7 @@ size_t RM_GetClusterSize(void) { * * REDISMODULE_NODE_FAIL: The cluster agrees the node is failing * * REDISMODULE_NODE_NOFAILOVER: The slave is configured to never failover */ -int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { +int RM_GetClusterNodeInfo(RedictModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { UNUSED(ctx); clusterNode *node = clusterLookupNode(id, strlen(id)); @@ -9078,7 +9078,7 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * partitioning according to the Redis Cluster algorithm. * Slots information will still be propagated across the * cluster, but without effect. */ -void RM_SetClusterFlags(RedisModuleCtx *ctx, uint64_t flags) { +void RM_SetClusterFlags(RedictModuleCtx *ctx, uint64_t flags) { UNUSED(ctx); if (flags & REDISMODULE_CLUSTER_FLAG_NO_FAILOVER) server.cluster_module_flags |= CLUSTER_MODULE_FLAG_NO_FAILOVER; @@ -9088,7 +9088,7 @@ void RM_SetClusterFlags(RedisModuleCtx *ctx, uint64_t flags) { /* Returns the cluster slot of a key, similar to the `CLUSTER KEYSLOT` command. * This function works even if cluster mode is not enabled. */ -unsigned int RM_ClusterKeySlot(RedisModuleString *key) { +unsigned int RM_ClusterKeySlot(RedictModuleString *key) { return keyHashSlot(key->ptr, sdslen(key->ptr)); } @@ -9121,15 +9121,15 @@ const char *RM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { static rax *Timers; /* The radix tree of all the timers sorted by expire. */ long long aeTimer = -1; /* Main event loop (ae.c) timer identifier. */ -typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data); +typedef void (*RedictModuleTimerProc)(RedictModuleCtx *ctx, void *data); /* The timer descriptor, stored as value in the radix tree. */ -typedef struct RedisModuleTimer { - RedisModule *module; /* Module reference. */ - RedisModuleTimerProc callback; /* The callback to invoke on expire. */ +typedef struct RedictModuleTimer { + RedictModule *module; /* Module reference. */ + RedictModuleTimerProc callback; /* The callback to invoke on expire. */ void *data; /* Private data for the callback. */ int dbid; /* Database number selected by the original client. */ -} RedisModuleTimer; +} RedictModuleTimer; /* This is the timer handler that is called by the main event loop. We schedule * this timer to be called when the nearest of our module timers will expire. */ @@ -9150,8 +9150,8 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client memcpy(&expiretime,ri.key,sizeof(expiretime)); expiretime = ntohu64(expiretime); if (now >= expiretime) { - RedisModuleTimer *timer = ri.data; - RedisModuleCtx ctx; + RedictModuleTimer *timer = ri.data; + RedictModuleCtx ctx; moduleCreateContext(&ctx,timer->module,REDISMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, timer->dbid); timer->callback(&ctx,timer->data); @@ -9185,7 +9185,7 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client * the specified function using `data` as argument. The returned timer ID can be * used to get information from the timer or to stop it before it fires. * Note that for the common use case of a repeating timer (Re-registration - * of the timer inside the RedisModuleTimerProc callback) it matters when + * of the timer inside the RedictModuleTimerProc callback) it matters when * this API is called: * If it is called at the beginning of 'callback' it means * the event will triggered every 'period'. @@ -9193,8 +9193,8 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client * there will 'period' milliseconds gaps between events. * (If the time it takes to execute 'callback' is negligible the two * statements above mean the same) */ -RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisModuleTimerProc callback, void *data) { - RedisModuleTimer *timer = zmalloc(sizeof(*timer)); +RedictModuleTimerID RM_CreateTimer(RedictModuleCtx *ctx, mstime_t period, RedictModuleTimerProc callback, void *data) { + RedictModuleTimer *timer = zmalloc(sizeof(*timer)); timer->module = ctx->module; timer->callback = callback; timer->data = data; @@ -9242,11 +9242,11 @@ RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisMod * calling module, and was stopped, otherwise REDISMODULE_ERR is returned. * If not NULL, the data pointer is set to the value of the data argument when * the timer was created. */ -int RM_StopTimer(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) { +int RM_StopTimer(RedictModuleCtx *ctx, RedictModuleTimerID id, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + RedictModuleTimer *timer = result; if (timer->module != ctx->module) return REDISMODULE_ERR; if (data) *data = timer->data; @@ -9261,11 +9261,11 @@ int RM_StopTimer(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) { * no information is returned and the function returns REDISMODULE_ERR, otherwise * REDISMODULE_OK is returned. The arguments remaining or data can be NULL if * the caller does not need certain information. */ -int RM_GetTimerInfo(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remaining, void **data) { +int RM_GetTimerInfo(RedictModuleCtx *ctx, RedictModuleTimerID id, uint64_t *remaining, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + RedictModuleTimer *timer = result; if (timer->module != ctx->module) return REDISMODULE_ERR; if (remaining) { @@ -9279,13 +9279,13 @@ int RM_GetTimerInfo(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remain /* Query timers to see if any timer belongs to the module. * Return 1 if any timer was found, otherwise 0 would be returned. */ -int moduleHoldsTimer(struct RedisModule *module) { +int moduleHoldsTimer(struct RedictModule *module) { raxIterator iter; int found = 0; raxStart(&iter,Timers); raxSeek(&iter,"^",NULL,0); while (raxNext(&iter)) { - RedisModuleTimer *timer = iter.data; + RedictModuleTimer *timer = iter.data; if (timer->module == module) { found = 1; break; @@ -9300,13 +9300,13 @@ int moduleHoldsTimer(struct RedisModule *module) { * --------------------------------------------------------------------------*/ typedef struct EventLoopData { - RedisModuleEventLoopFunc rFunc; - RedisModuleEventLoopFunc wFunc; + RedictModuleEventLoopFunc rFunc; + RedictModuleEventLoopFunc wFunc; void *user_data; } EventLoopData; typedef struct EventLoopOneShot { - RedisModuleEventLoopOneShotFunc func; + RedictModuleEventLoopOneShotFunc func; void *user_data; } EventLoopOneShot; @@ -9368,7 +9368,7 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * } * RM_EventLoopAdd(fd, REDISMODULE_EVENTLOOP_READABLE, onReadable, NULL); */ -int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_data) { +int RM_EventLoopAdd(int fd, int mask, RedictModuleEventLoopFunc func, void *user_data) { if (fd < 0 || fd >= aeGetSetSize(server.el)) { errno = ERANGE; return REDISMODULE_ERR; @@ -9382,7 +9382,7 @@ int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_ /* We are going to register stub callbacks to 'ae' for two reasons: * - * - "ae" callback signature is different from RedisModuleEventLoopCallback, + * - "ae" callback signature is different from RedictModuleEventLoopCallback, * that will be handled it in our stub callbacks. * - We need to remap 'mask' value to provide binary compatibility. * @@ -9459,7 +9459,7 @@ int RM_EventLoopDel(int fd, int mask) { * main thread. On success REDISMODULE_OK is returned. If `func` is NULL * REDISMODULE_ERR is returned and errno is set to EINVAL. */ -int RM_EventLoopAddOneShot(RedisModuleEventLoopOneShotFunc func, void *user_data) { +int RM_EventLoopAddOneShot(RedictModuleEventLoopOneShotFunc func, void *user_data) { if (!func) { errno = EINVAL; return REDISMODULE_ERR; @@ -9550,7 +9550,7 @@ void revokeClientAuthentication(client *c) { /* Cleanup all clients that have been authenticated with this module. This * is called from onUnload() to give the module a chance to cleanup any * resources associated with clients it has authenticated. */ -static void moduleFreeAuthenticatedClients(RedisModule *module) { +static void moduleFreeAuthenticatedClients(RedictModule *module) { listIter li; listNode *ln; listRewind(server.clients,&li); @@ -9558,7 +9558,7 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { client *c = listNodeValue(ln); if (!c->auth_module) continue; - RedisModule *auth_module = (RedisModule *) c->auth_module; + RedictModule *auth_module = (RedictModule *) c->auth_module; if (auth_module == module) { revokeClientAuthentication(c); } @@ -9569,7 +9569,7 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { * After obtaining the user, the module should set what such user can do * using the RM_SetUserACL() function. Once configured, the user * can be used in order to authenticate a connection, with the specified - * ACL rules, using the RedisModule_AuthClientWithUser() function. + * ACL rules, using the RedictModule_AuthClientWithUser() function. * * Note that: * @@ -9585,8 +9585,8 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { * The function to free the user should only be used when the caller really * wants to invalidate the user to define a new one with different * capabilities. */ -RedisModuleUser *RM_CreateModuleUser(const char *name) { - RedisModuleUser *new_user = zmalloc(sizeof(RedisModuleUser)); +RedictModuleUser *RM_CreateModuleUser(const char *name) { + RedictModuleUser *new_user = zmalloc(sizeof(RedictModuleUser)); new_user->user = ACLCreateUnlinkedUser(); new_user->free_user = 1; @@ -9598,7 +9598,7 @@ RedisModuleUser *RM_CreateModuleUser(const char *name) { /* Frees a given user and disconnects all of the clients that have been * authenticated with it. See RM_CreateModuleUser for detailed usage.*/ -int RM_FreeModuleUser(RedisModuleUser *user) { +int RM_FreeModuleUser(RedictModuleUser *user) { if (user->free_user) ACLFreeUserAndKillClients(user->user); zfree(user); @@ -9612,7 +9612,7 @@ int RM_FreeModuleUser(RedisModuleUser *user) { * * Returns REDISMODULE_OK on success and REDISMODULE_ERR on failure * and will set an errno describing why the operation failed. */ -int RM_SetModuleUserACL(RedisModuleUser *user, const char* acl) { +int RM_SetModuleUserACL(RedictModuleUser *user, const char* acl) { return ACLSetUser(user->user, acl, -1); } @@ -9621,9 +9621,9 @@ int RM_SetModuleUserACL(RedisModuleUser *user, const char* acl) { * RM_SetModuleUserACL, which only takes single ACL operations at a time. * * Returns REDISMODULE_OK on success and REDISMODULE_ERR on failure - * if a RedisModuleString is provided in error, a string describing the error + * if a RedictModuleString is provided in error, a string describing the error * will be returned */ -int RM_SetModuleUserACLString(RedisModuleCtx *ctx, RedisModuleUser *user, const char *acl, RedisModuleString **error) { +int RM_SetModuleUserACLString(RedictModuleCtx *ctx, RedictModuleUser *user, const char *acl, RedictModuleString **error) { serverAssert(user != NULL); int argc; @@ -9648,43 +9648,43 @@ int RM_SetModuleUserACLString(RedisModuleCtx *ctx, RedisModuleUser *user, const } /* Get the ACL string for a given user - * Returns a RedisModuleString + * Returns a RedictModuleString */ -RedisModuleString *RM_GetModuleUserACLString(RedisModuleUser *user) { +RedictModuleString *RM_GetModuleUserACLString(RedictModuleUser *user) { serverAssert(user != NULL); return ACLDescribeUser(user->user); } /* Retrieve the user name of the client connection behind the current context. - * The user name can be used later, in order to get a RedisModuleUser. + * The user name can be used later, in order to get a RedictModuleUser. * See more information in RM_GetModuleUserFromUserName. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with RedictModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_GetCurrentUserName(RedisModuleCtx *ctx) { +RedictModuleString *RM_GetCurrentUserName(RedictModuleCtx *ctx) { return RM_CreateString(ctx,ctx->client->user->name,sdslen(ctx->client->user->name)); } -/* A RedisModuleUser can be used to check if command, key or channel can be executed or +/* A RedictModuleUser can be used to check if command, key or channel can be executed or * accessed according to the ACLs rules associated with that user. * When a Module wants to do ACL checks on a general ACL user (not created by RM_CreateModuleUser), - * it can get the RedisModuleUser from this API, based on the user name retrieved by RM_GetCurrentUserName. + * it can get the RedictModuleUser from this API, based on the user name retrieved by RM_GetCurrentUserName. * - * Since a general ACL user can be deleted at any time, this RedisModuleUser should be used only in the context + * Since a general ACL user can be deleted at any time, this RedictModuleUser should be used only in the context * where this function was called. In order to do ACL checks out of that context, the Module can store the user name, * and call this API at any other context. * * Returns NULL if the user is disabled or the user does not exist. * The caller should later free the user using the function RM_FreeModuleUser().*/ -RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { +RedictModuleUser *RM_GetModuleUserFromUserName(RedictModuleString *name) { /* First, verify that the user exist */ user *acl_user = ACLGetUserByName(name->ptr, sdslen(name->ptr)); if (acl_user == NULL) { return NULL; } - RedisModuleUser *new_user = zmalloc(sizeof(RedisModuleUser)); + RedictModuleUser *new_user = zmalloc(sizeof(RedictModuleUser)); new_user->user = acl_user; new_user->free_user = 0; return new_user; @@ -9698,7 +9698,7 @@ RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { * * ENOENT: Specified command does not exist. * * EACCES: Command cannot be executed, according to ACL rules */ -int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **argv, int argc) { +int RM_ACLCheckCommandPermissions(RedictModuleUser *user, RedictModuleString **argv, int argc) { int keyidxptr; struct redictCommand *cmd; @@ -9718,7 +9718,7 @@ int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **arg /* Check if the key can be accessed by the user according to the ACLs attached to the user * and the flags representing the key access. The flags are the same that are used in the - * keyspec for logical operations. These flags are documented in RedisModule_SetCommandInfo as + * keyspec for logical operations. These flags are documented in RedictModule_SetCommandInfo as * the REDISMODULE_CMD_KEY_ACCESS, REDISMODULE_CMD_KEY_UPDATE, REDISMODULE_CMD_KEY_INSERT, * and REDISMODULE_CMD_KEY_DELETE flags. * @@ -9731,7 +9731,7 @@ int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **arg * * EINVAL: The provided flags are invalid. * * EACCESS: The user does not have permission to access the key. */ -int RM_ACLCheckKeyPermissions(RedisModuleUser *user, RedisModuleString *key, int flags) { +int RM_ACLCheckKeyPermissions(RedictModuleUser *user, RedictModuleString *key, int flags) { const int allow_mask = (REDISMODULE_CMD_KEY_ACCESS | REDISMODULE_CMD_KEY_INSERT | REDISMODULE_CMD_KEY_DELETE @@ -9761,7 +9761,7 @@ int RM_ACLCheckKeyPermissions(RedisModuleUser *user, RedisModuleString *key, int * * EINVAL: The provided flags are invalid. * * EACCESS: The user does not have permission to access the pubsub channel. */ -int RM_ACLCheckChannelPermissions(RedisModuleUser *user, RedisModuleString *ch, int flags) { +int RM_ACLCheckChannelPermissions(RedictModuleUser *user, RedictModuleString *ch, int flags) { const int allow_mask = (REDISMODULE_CMD_CHANNEL_PUBLISH | REDISMODULE_CMD_CHANNEL_SUBSCRIBE | REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE @@ -9784,8 +9784,8 @@ int RM_ACLCheckChannelPermissions(RedisModuleUser *user, RedisModuleString *ch, return REDISMODULE_OK; } -/* Helper function to map a RedisModuleACLLogEntryReason to ACL Log entry reason. */ -int moduleGetACLLogEntryReason(RedisModuleACLLogEntryReason reason) { +/* Helper function to map a RedictModuleACLLogEntryReason to ACL Log entry reason. */ +int moduleGetACLLogEntryReason(RedictModuleACLLogEntryReason reason) { int acl_reason = 0; switch (reason) { case REDISMODULE_ACL_LOG_AUTH: acl_reason = ACL_DENIED_AUTH; break; @@ -9801,18 +9801,18 @@ int moduleGetACLLogEntryReason(RedisModuleACLLogEntryReason reason) { * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. * * For more information about ACL log, please refer to https://redis.io/commands/acl-log */ -int RM_ACLAddLogEntry(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) { +int RM_ACLAddLogEntry(RedictModuleCtx *ctx, RedictModuleUser *user, RedictModuleString *object, RedictModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); if (!acl_reason) return REDISMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, user->user->name, sdsdup(object->ptr)); return REDISMODULE_OK; } -/* Adds a new entry in the ACL log with the `username` RedisModuleString provided. +/* Adds a new entry in the ACL log with the `username` RedictModuleString provided. * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. * * For more information about ACL log, please refer to https://redis.io/commands/acl-log */ -int RM_ACLAddLogEntryByUserName(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *object, RedisModuleACLLogEntryReason reason) { +int RM_ACLAddLogEntryByUserName(RedictModuleCtx *ctx, RedictModuleString *username, RedictModuleString *object, RedictModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); if (!acl_reason) return REDISMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, username->ptr, sdsdup(object->ptr)); @@ -9839,7 +9839,7 @@ int RM_ACLAddLogEntryByUserName(RedisModuleCtx *ctx, RedisModuleString *username * For expensive authentication operations, it is recommended to block the * client and do the authentication in the background and then attach the user * to the client in a threadsafe context. */ -static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +static int authenticateClientWithUser(RedictModuleCtx *ctx, user *user, RedictModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { if (user->flags & USER_FLAG_DISABLED) { return REDISMODULE_ERR; } @@ -9877,7 +9877,7 @@ static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModu * * See authenticateClientWithUser for information about callback, client_id, * and general usage for authentication. */ -int RM_AuthenticateClientWithUser(RedisModuleCtx *ctx, RedisModuleUser *module_user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +int RM_AuthenticateClientWithUser(RedictModuleCtx *ctx, RedictModuleUser *module_user, RedictModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { return authenticateClientWithUser(ctx, module_user->user, callback, privdata, client_id); } @@ -9886,7 +9886,7 @@ int RM_AuthenticateClientWithUser(RedisModuleCtx *ctx, RedisModuleUser *module_u * * See authenticateClientWithUser for information about callback, client_id, * and general usage for authentication. */ -int RM_AuthenticateClientWithACLUser(RedisModuleCtx *ctx, const char *name, size_t len, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { +int RM_AuthenticateClientWithACLUser(RedictModuleCtx *ctx, const char *name, size_t len, RedictModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { user *acl_user = ACLGetUserByName(name, len); if (!acl_user) { @@ -9907,7 +9907,7 @@ int RM_AuthenticateClientWithACLUser(RedisModuleCtx *ctx, const char *name, size * * This function is not thread safe, and must be executed within the context * of a command or thread safe context. */ -int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id) { +int RM_DeauthenticateAndCloseClient(RedictModuleCtx *ctx, uint64_t client_id) { UNUSED(ctx); client *c = lookupClientByID(client_id); if (c == NULL) return REDISMODULE_ERR; @@ -9927,7 +9927,7 @@ int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id) { * Returns REDISMODULE_OK if the argument was redacted and REDISMODULE_ERR if there * was an invalid parameter passed in or the position is outside the client * argument range. */ -int RM_RedactClientCommandArgument(RedisModuleCtx *ctx, int pos) { +int RM_RedactClientCommandArgument(RedictModuleCtx *ctx, int pos) { if (!ctx || !ctx->client || pos <= 0 || ctx->client->argc <= pos) { return REDISMODULE_ERR; } @@ -9938,7 +9938,7 @@ int RM_RedactClientCommandArgument(RedisModuleCtx *ctx, int pos) { /* Return the X.509 client-side certificate used by the client to authenticate * this connection. * - * The return value is an allocated RedisModuleString that is a X.509 certificate + * The return value is an allocated RedictModuleString that is a X.509 certificate * encoded in PEM (Base64) format. It should be freed (or auto-freed) by the caller. * * A NULL value is returned in the following conditions: @@ -9947,14 +9947,14 @@ int RM_RedactClientCommandArgument(RedisModuleCtx *ctx, int pos) { * - Connection is not a TLS connection * - Connection is a TLS connection but no client certificate was used */ -RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_id) { +RedictModuleString *RM_GetClientCertificate(RedictModuleCtx *ctx, uint64_t client_id) { client *c = lookupClientByID(client_id); if (c == NULL) return NULL; sds cert = connGetPeerCert(c->conn); if (!cert) return NULL; - RedisModuleString *s = createObject(OBJ_STRING, cert); + RedictModuleString *s = createObject(OBJ_STRING, cert); if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, s); return s; @@ -9981,8 +9981,8 @@ RedisModuleString *RM_GetClientCertificate(RedisModuleCtx *ctx, uint64_t client_ * reclaim the dictionary memory, as well as the strings returned by the * Next / Prev dictionary iterator calls. */ -RedisModuleDict *RM_CreateDict(RedisModuleCtx *ctx) { - struct RedisModuleDict *d = zmalloc(sizeof(*d)); +RedictModuleDict *RM_CreateDict(RedictModuleCtx *ctx) { + struct RedictModuleDict *d = zmalloc(sizeof(*d)); d->rax = raxNew(); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_DICT,d); return d; @@ -9991,14 +9991,14 @@ RedisModuleDict *RM_CreateDict(RedisModuleCtx *ctx) { /* Free a dictionary created with RM_CreateDict(). You need to pass the * context pointer 'ctx' only if the dictionary was created using the * context instead of passing NULL. */ -void RM_FreeDict(RedisModuleCtx *ctx, RedisModuleDict *d) { +void RM_FreeDict(RedictModuleCtx *ctx, RedictModuleDict *d) { if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_DICT,d); raxFree(d->rax); zfree(d); } /* Return the size of the dictionary (number of keys). */ -uint64_t RM_DictSize(RedisModuleDict *d) { +uint64_t RM_DictSize(RedictModuleDict *d) { return raxSize(d->rax); } @@ -10006,25 +10006,25 @@ uint64_t RM_DictSize(RedisModuleDict *d) { * pointer 'ptr'. If the key was added with success, since it did not * already exist, REDISMODULE_OK is returned. Otherwise if the key already * exists the function returns REDISMODULE_ERR. */ -int RM_DictSetC(RedisModuleDict *d, void *key, size_t keylen, void *ptr) { +int RM_DictSetC(RedictModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxTryInsert(d->rax,key,keylen,ptr,NULL); return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; } -/* Like RedisModule_DictSetC() but will replace the key with the new +/* Like RedictModule_DictSetC() but will replace the key with the new * value if the key already exists. */ -int RM_DictReplaceC(RedisModuleDict *d, void *key, size_t keylen, void *ptr) { +int RM_DictReplaceC(RedictModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxInsert(d->rax,key,keylen,ptr,NULL); return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; } -/* Like RedisModule_DictSetC() but takes the key as a RedisModuleString. */ -int RM_DictSet(RedisModuleDict *d, RedisModuleString *key, void *ptr) { +/* Like RedictModule_DictSetC() but takes the key as a RedictModuleString. */ +int RM_DictSet(RedictModuleDict *d, RedictModuleString *key, void *ptr) { return RM_DictSetC(d,key->ptr,sdslen(key->ptr),ptr); } -/* Like RedisModule_DictReplaceC() but takes the key as a RedisModuleString. */ -int RM_DictReplace(RedisModuleDict *d, RedisModuleString *key, void *ptr) { +/* Like RedictModule_DictReplaceC() but takes the key as a RedictModuleString. */ +int RM_DictReplace(RedictModuleDict *d, RedictModuleString *key, void *ptr) { return RM_DictReplaceC(d,key->ptr,sdslen(key->ptr),ptr); } @@ -10033,15 +10033,15 @@ int RM_DictReplace(RedisModuleDict *d, RedisModuleString *key, void *ptr) { * NULL at key. So, optionally, if the 'nokey' pointer is not NULL, it will * be set by reference to 1 if the key does not exist, or to 0 if the key * exists. */ -void *RM_DictGetC(RedisModuleDict *d, void *key, size_t keylen, int *nokey) { +void *RM_DictGetC(RedictModuleDict *d, void *key, size_t keylen, int *nokey) { void *res = NULL; int found = raxFind(d->rax,key,keylen,&res); if (nokey) *nokey = !found; return res; } -/* Like RedisModule_DictGetC() but takes the key as a RedisModuleString. */ -void *RM_DictGet(RedisModuleDict *d, RedisModuleString *key, int *nokey) { +/* Like RedictModule_DictGetC() but takes the key as a RedictModuleString. */ +void *RM_DictGet(RedictModuleDict *d, RedictModuleString *key, int *nokey) { return RM_DictGetC(d,key->ptr,sdslen(key->ptr),nokey); } @@ -10051,14 +10051,14 @@ void *RM_DictGet(RedisModuleDict *d, RedisModuleString *key, int *nokey) { * 'oldval' is not NULL, then '*oldval' is set to the value stored at the * key before it was deleted. Using this feature it is possible to get * a pointer to the value (for instance in order to release it), without - * having to call RedisModule_DictGet() before deleting the key. */ -int RM_DictDelC(RedisModuleDict *d, void *key, size_t keylen, void *oldval) { + * having to call RedictModule_DictGet() before deleting the key. */ +int RM_DictDelC(RedictModuleDict *d, void *key, size_t keylen, void *oldval) { int retval = raxRemove(d->rax,key,keylen,oldval); return retval ? REDISMODULE_OK : REDISMODULE_ERR; } -/* Like RedisModule_DictDelC() but gets the key as a RedisModuleString. */ -int RM_DictDel(RedisModuleDict *d, RedisModuleString *key, void *oldval) { +/* Like RedictModule_DictDelC() but gets the key as a RedictModuleString. */ +int RM_DictDel(RedictModuleDict *d, RedictModuleString *key, void *oldval) { return RM_DictDelC(d,key->ptr,sdslen(key->ptr),oldval); } @@ -10079,44 +10079,44 @@ int RM_DictDel(RedisModuleDict *d, RedisModuleString *key, void *oldval) { * just pass NULL with a length of 0. * * If the element to start the iteration cannot be seeked based on the - * key and operator passed, RedisModule_DictNext() / Prev() will just return + * key and operator passed, RedictModule_DictNext() / Prev() will just return * REDISMODULE_ERR at the first call, otherwise they'll produce elements. */ -RedisModuleDictIter *RM_DictIteratorStartC(RedisModuleDict *d, const char *op, void *key, size_t keylen) { - RedisModuleDictIter *di = zmalloc(sizeof(*di)); +RedictModuleDictIter *RM_DictIteratorStartC(RedictModuleDict *d, const char *op, void *key, size_t keylen) { + RedictModuleDictIter *di = zmalloc(sizeof(*di)); di->dict = d; raxStart(&di->ri,d->rax); raxSeek(&di->ri,op,key,keylen); return di; } -/* Exactly like RedisModule_DictIteratorStartC, but the key is passed as a - * RedisModuleString. */ -RedisModuleDictIter *RM_DictIteratorStart(RedisModuleDict *d, const char *op, RedisModuleString *key) { +/* Exactly like RedictModule_DictIteratorStartC, but the key is passed as a + * RedictModuleString. */ +RedictModuleDictIter *RM_DictIteratorStart(RedictModuleDict *d, const char *op, RedictModuleString *key) { return RM_DictIteratorStartC(d,op,key->ptr,sdslen(key->ptr)); } -/* Release the iterator created with RedisModule_DictIteratorStart(). This call +/* Release the iterator created with RedictModule_DictIteratorStart(). This call * is mandatory otherwise a memory leak is introduced in the module. */ -void RM_DictIteratorStop(RedisModuleDictIter *di) { +void RM_DictIteratorStop(RedictModuleDictIter *di) { raxStop(&di->ri); zfree(di); } -/* After its creation with RedisModule_DictIteratorStart(), it is possible to +/* After its creation with RedictModule_DictIteratorStart(), it is possible to * change the currently selected element of the iterator by using this * API call. The result based on the operator and key is exactly like - * the function RedisModule_DictIteratorStart(), however in this case the + * the function RedictModule_DictIteratorStart(), however in this case the * return value is just REDISMODULE_OK in case the seeked element was found, * or REDISMODULE_ERR in case it was not possible to seek the specified * element. It is possible to reseek an iterator as many times as you want. */ -int RM_DictIteratorReseekC(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) { +int RM_DictIteratorReseekC(RedictModuleDictIter *di, const char *op, void *key, size_t keylen) { return raxSeek(&di->ri,op,key,keylen); } -/* Like RedisModule_DictIteratorReseekC() but takes the key as a - * RedisModuleString. */ -int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleString *key) { +/* Like RedictModule_DictIteratorReseekC() but takes the key as a + * RedictModuleString. */ +int RM_DictIteratorReseek(RedictModuleDictIter *di, const char *op, RedictModuleString *key) { return RM_DictIteratorReseekC(di,op,key->ptr,sdslen(key->ptr)); } @@ -10126,14 +10126,14 @@ int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleSt * to a string representing the key is provided, and the `*keylen` length * is set by reference (if keylen is not NULL). The `*dataptr`, if not NULL * is set to the value of the pointer stored at the returned key as auxiliary - * data (as set by the RedisModule_DictSet API). + * data (as set by the RedictModule_DictSet API). * * Usage example: * * ... create the iterator here ... * char *key; * void *data; - * while((key = RedisModule_DictNextC(iter,&keylen,&data)) != NULL) { + * while((key = RedictModule_DictNextC(iter,&keylen,&data)) != NULL) { * printf("%.*s %p\n", (int)keylen, key, data); * } * @@ -10145,41 +10145,41 @@ int RM_DictIteratorReseek(RedisModuleDictIter *di, const char *op, RedisModuleSt * The validity of the returned pointer is until the next call to the * next/prev iterator step. Also the pointer is no longer valid once the * iterator is released. */ -void *RM_DictNextC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) { +void *RM_DictNextC(RedictModuleDictIter *di, size_t *keylen, void **dataptr) { if (!raxNext(&di->ri)) return NULL; if (keylen) *keylen = di->ri.key_len; if (dataptr) *dataptr = di->ri.data; return di->ri.key; } -/* This function is exactly like RedisModule_DictNext() but after returning +/* This function is exactly like RedictModule_DictNext() but after returning * the currently selected element in the iterator, it selects the previous * element (lexicographically smaller) instead of the next one. */ -void *RM_DictPrevC(RedisModuleDictIter *di, size_t *keylen, void **dataptr) { +void *RM_DictPrevC(RedictModuleDictIter *di, size_t *keylen, void **dataptr) { if (!raxPrev(&di->ri)) return NULL; if (keylen) *keylen = di->ri.key_len; if (dataptr) *dataptr = di->ri.data; return di->ri.key; } -/* Like RedisModuleNextC(), but instead of returning an internally allocated +/* Like RedictModuleNextC(), but instead of returning an internally allocated * buffer and key length, it returns directly a module string object allocated * in the specified context 'ctx' (that may be NULL exactly like for the main - * API RedisModule_CreateString). + * API RedictModule_CreateString). * * The returned string object should be deallocated after use, either manually * or by using a context that has automatic memory management active. */ -RedisModuleString *RM_DictNext(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) { +RedictModuleString *RM_DictNext(RedictModuleCtx *ctx, RedictModuleDictIter *di, void **dataptr) { size_t keylen; void *key = RM_DictNextC(di,&keylen,dataptr); if (key == NULL) return NULL; return RM_CreateString(ctx,key,keylen); } -/* Like RedisModule_DictNext() but after returning the currently selected +/* Like RedictModule_DictNext() but after returning the currently selected * element in the iterator, it selects the previous element (lexicographically * smaller) instead of the next one. */ -RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) { +RedictModuleString *RM_DictPrev(RedictModuleCtx *ctx, RedictModuleDictIter *di, void **dataptr) { size_t keylen; void *key = RM_DictPrevC(di,&keylen,dataptr); if (key == NULL) return NULL; @@ -10188,7 +10188,7 @@ RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, voi /* Compare the element currently pointed by the iterator to the specified * element given by key/keylen, according to the operator 'op' (the set of - * valid operators are the same valid for RedisModule_DictIteratorStart). + * valid operators are the same valid for RedictModule_DictIteratorStart). * If the comparison is successful the command returns REDISMODULE_OK * otherwise REDISMODULE_ERR is returned. * @@ -10198,15 +10198,15 @@ RedisModuleString *RM_DictPrev(RedisModuleCtx *ctx, RedisModuleDictIter *di, voi * * The function return REDISMODULE_ERR if the iterator reached the * end of elements condition as well. */ -int RM_DictCompareC(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) { +int RM_DictCompareC(RedictModuleDictIter *di, const char *op, void *key, size_t keylen) { if (raxEOF(&di->ri)) return REDISMODULE_ERR; int res = raxCompare(&di->ri,op,key,keylen); return res ? REDISMODULE_OK : REDISMODULE_ERR; } -/* Like RedisModule_DictCompareC but gets the key to compare with the current - * iterator key as a RedisModuleString. */ -int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *key) { +/* Like RedictModule_DictCompareC but gets the key to compare with the current + * iterator key as a RedictModuleString. */ +int RM_DictCompare(RedictModuleDictIter *di, const char *op, RedictModuleString *key) { if (raxEOF(&di->ri)) return REDISMODULE_ERR; int res = raxCompare(&di->ri,op,key->ptr,sdslen(key->ptr)); return res ? REDISMODULE_OK : REDISMODULE_ERR; @@ -10219,13 +10219,13 @@ int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *k * ## Modules Info fields * -------------------------------------------------------------------------- */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx); +int RM_InfoEndDictField(RedictModuleInfoCtx *ctx); /* Used to start a new section, before adding any fields. the section name will * be prefixed by `_` and must only include A-Z,a-z,0-9. * NULL or empty string indicates the default section (only ``) is used. * When return value is REDISMODULE_ERR, the section should and will be skipped. */ -int RM_InfoAddSection(RedisModuleInfoCtx *ctx, const char *name) { +int RM_InfoAddSection(RedictModuleInfoCtx *ctx, const char *name) { sds full_name = sdsdup(ctx->module->name); if (name != NULL && strlen(name) > 0) full_name = sdscatfmt(full_name, "_%s", name); @@ -10255,9 +10255,9 @@ int RM_InfoAddSection(RedisModuleInfoCtx *ctx, const char *name) { } /* Starts a dict field, similar to the ones in INFO KEYSPACE. Use normal - * RedisModule_InfoAddField* functions to add the items to this field, and - * terminate with RedisModule_InfoEndDictField. */ -int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, const char *name) { + * RedictModule_InfoAddField* functions to add the items to this field, and + * terminate with RedictModule_InfoEndDictField. */ +int RM_InfoBeginDictField(RedictModuleInfoCtx *ctx, const char *name) { if (!ctx->in_section) return REDISMODULE_ERR; /* Implicitly end dicts, instead of returning an error which is likely un checked. */ @@ -10274,8 +10274,8 @@ int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, const char *name) { return REDISMODULE_OK; } -/* Ends a dict field, see RedisModule_InfoBeginDictField */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx) { +/* Ends a dict field, see RedictModule_InfoBeginDictField */ +int RM_InfoEndDictField(RedictModuleInfoCtx *ctx) { if (!ctx->in_dict_field) return REDISMODULE_ERR; /* trim the last ',' if found. */ @@ -10286,10 +10286,10 @@ int RM_InfoEndDictField(RedisModuleInfoCtx *ctx) { return REDISMODULE_OK; } -/* Used by RedisModuleInfoFunc to add info fields. +/* Used by RedictModuleInfoFunc to add info fields. * Each field will be automatically prefixed by `_`. * Field names or values must not include `\r\n` or `:`. */ -int RM_InfoAddFieldString(RedisModuleInfoCtx *ctx, const char *field, RedisModuleString *value) { +int RM_InfoAddFieldString(RedictModuleInfoCtx *ctx, const char *field, RedictModuleString *value) { if (!ctx->in_section) return REDISMODULE_ERR; if (ctx->in_dict_field) { @@ -10307,8 +10307,8 @@ int RM_InfoAddFieldString(RedisModuleInfoCtx *ctx, const char *field, RedisModul return REDISMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldCString(RedisModuleInfoCtx *ctx, const char *field, const char *value) { +/* See RedictModule_InfoAddFieldString(). */ +int RM_InfoAddFieldCString(RedictModuleInfoCtx *ctx, const char *field, const char *value) { if (!ctx->in_section) return REDISMODULE_ERR; if (ctx->in_dict_field) { @@ -10326,8 +10326,8 @@ int RM_InfoAddFieldCString(RedisModuleInfoCtx *ctx, const char *field, const cha return REDISMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldDouble(RedisModuleInfoCtx *ctx, const char *field, double value) { +/* See RedictModule_InfoAddFieldString(). */ +int RM_InfoAddFieldDouble(RedictModuleInfoCtx *ctx, const char *field, double value) { if (!ctx->in_section) return REDISMODULE_ERR; if (ctx->in_dict_field) { @@ -10345,8 +10345,8 @@ int RM_InfoAddFieldDouble(RedisModuleInfoCtx *ctx, const char *field, double val return REDISMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldLongLong(RedisModuleInfoCtx *ctx, const char *field, long long value) { +/* See RedictModule_InfoAddFieldString(). */ +int RM_InfoAddFieldLongLong(RedictModuleInfoCtx *ctx, const char *field, long long value) { if (!ctx->in_section) return REDISMODULE_ERR; if (ctx->in_dict_field) { @@ -10364,8 +10364,8 @@ int RM_InfoAddFieldLongLong(RedisModuleInfoCtx *ctx, const char *field, long lon return REDISMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) { +/* See RedictModule_InfoAddFieldString(). */ +int RM_InfoAddFieldULongLong(RedictModuleInfoCtx *ctx, const char *field, unsigned long long value) { if (!ctx->in_section) return REDISMODULE_ERR; if (ctx->in_dict_field) { @@ -10384,8 +10384,8 @@ int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, const char *field, unsigne } /* Registers callback for the INFO command. The callback should add INFO fields - * by calling the `RedisModule_InfoAddField*()` functions. */ -int RM_RegisterInfoFunc(RedisModuleCtx *ctx, RedisModuleInfoFunc cb) { + * by calling the `RedictModule_InfoAddField*()` functions. */ +int RM_RegisterInfoFunc(RedictModuleCtx *ctx, RedictModuleInfoFunc cb) { ctx->module->info_cb = cb; return REDISMODULE_OK; } @@ -10395,10 +10395,10 @@ sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); if (!module->info_cb) continue; - RedisModuleInfoCtx info_ctx = {module, sections_dict, info, sections, 0, 0}; + RedictModuleInfoCtx info_ctx = {module, sections_dict, info, sections, 0, 0}; module->info_cb(&info_ctx, for_crash_report); /* Implicitly end dicts (no way to handle errors, and we must add the newline). */ if (info_ctx.in_dict_field) @@ -10413,11 +10413,11 @@ sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int /* Get information about the server similar to the one that returns from the * INFO command. This function takes an optional 'section' argument that may * be NULL. The return value holds the output and can be used with - * RedisModule_ServerInfoGetField and alike to get the individual fields. - * When done, it needs to be freed with RedisModule_FreeServerInfo or with the + * RedictModule_ServerInfoGetField and alike to get the individual fields. + * When done, it needs to be freed with RedictModule_FreeServerInfo or with the * automatic memory management mechanism if enabled. */ -RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *section) { - struct RedisModuleServerInfoData *d = zmalloc(sizeof(*d)); +RedictModuleServerInfoData *RM_GetServerInfo(RedictModuleCtx *ctx, const char *section) { + struct RedictModuleServerInfoData *d = zmalloc(sizeof(*d)); d->rax = raxNew(); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_INFO,d); int all = 0, everything = 0; @@ -10448,7 +10448,7 @@ RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *sec /* Free data created with RM_GetServerInfo(). You need to pass the * context pointer 'ctx' only if the dictionary was created using the * context instead of passing NULL. */ -void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) { +void RM_FreeServerInfo(RedictModuleCtx *ctx, RedictModuleServerInfoData *data) { if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_INFO,data); raxFreeWithCallback(data->rax, (void(*)(void*))sdsfree); zfree(data); @@ -10458,18 +10458,18 @@ void RM_FreeServerInfo(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) { * need to pass the context pointer 'ctx' only if you want to use auto memory * mechanism to release the returned string. Return value will be NULL if the * field was not found. */ -RedisModuleString *RM_ServerInfoGetField(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field) { +RedictModuleString *RM_ServerInfoGetField(RedictModuleCtx *ctx, RedictModuleServerInfoData *data, const char* field) { void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) return NULL; sds val = result; - RedisModuleString *o = createStringObject(val,sdslen(val)); + RedictModuleString *o = createStringObject(val,sdslen(val)); if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); return o; } /* Similar to RM_ServerInfoGetField, but returns a char* which should not be freed but the caller. */ -const char *RM_ServerInfoGetFieldC(RedisModuleServerInfoData *data, const char* field) { +const char *RM_ServerInfoGetFieldC(RedictModuleServerInfoData *data, const char* field) { void *result = NULL; raxFind(data->rax, (unsigned char *)field, strlen(field), &result); return result; @@ -10478,7 +10478,7 @@ const char *RM_ServerInfoGetFieldC(RedisModuleServerInfoData *data, const char* /* Get the value of a field from data collected with RM_GetServerInfo(). If the * field is not found, or is not numerical or out of range, return value will be * 0, and the optional out_err argument will be set to REDISMODULE_ERR. */ -long long RM_ServerInfoGetFieldSigned(RedisModuleServerInfoData *data, const char* field, int *out_err) { +long long RM_ServerInfoGetFieldSigned(RedictModuleServerInfoData *data, const char* field, int *out_err) { long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { @@ -10497,7 +10497,7 @@ long long RM_ServerInfoGetFieldSigned(RedisModuleServerInfoData *data, const cha /* Get the value of a field from data collected with RM_GetServerInfo(). If the * field is not found, or is not numerical or out of range, return value will be * 0, and the optional out_err argument will be set to REDISMODULE_ERR. */ -unsigned long long RM_ServerInfoGetFieldUnsigned(RedisModuleServerInfoData *data, const char* field, int *out_err) { +unsigned long long RM_ServerInfoGetFieldUnsigned(RedictModuleServerInfoData *data, const char* field, int *out_err) { unsigned long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { @@ -10516,7 +10516,7 @@ unsigned long long RM_ServerInfoGetFieldUnsigned(RedisModuleServerInfoData *data /* Get the value of a field from data collected with RM_GetServerInfo(). If the * field is not found, or is not a double, return value will be 0, and the * optional out_err argument will be set to REDISMODULE_ERR. */ -double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* field, int *out_err) { +double RM_ServerInfoGetFieldDouble(RedictModuleServerInfoData *data, const char* field, int *out_err) { double dbl; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { @@ -10544,7 +10544,7 @@ void RM_GetRandomBytes(unsigned char *dst, size_t len) { getRandomBytes(dst,len); } -/* Like RedisModule_GetRandomBytes() but instead of setting the string to +/* Like RedictModule_GetRandomBytes() but instead of setting the string to * random bytes the string is set to random characters in the in the * hex charset [0-9a-f]. */ void RM_GetRandomHexChars(char *dst, size_t len) { @@ -10567,8 +10567,8 @@ void RM_GetRandomHexChars(char *dst, size_t len) { * IMPORTANT: the apiname argument should be a string literal with static * lifetime. The API relies on the fact that it will always be valid in * the future. */ -int RM_ExportSharedAPI(RedisModuleCtx *ctx, const char *apiname, void *func) { - RedisModuleSharedAPI *sapi = zmalloc(sizeof(*sapi)); +int RM_ExportSharedAPI(RedictModuleCtx *ctx, const char *apiname, void *func) { + RedictModuleSharedAPI *sapi = zmalloc(sizeof(*sapi)); sapi->module = ctx->module; sapi->func = func; if (dictAdd(server.sharedapi, (char*)apiname, sapi) != DICT_OK) { @@ -10605,16 +10605,16 @@ int RM_ExportSharedAPI(RedisModuleCtx *ctx, const char *apiname, void *func) { * static int api_loaded = 0; * if (api_loaded != 0) return 1; // APIs already resolved. * - * myFunctionPointer = RedisModule_GetSharedAPI("..."); + * myFunctionPointer = RedictModule_GetSharedAPI("..."); * if (myFunctionPointer == NULL) return 0; * * return 1; * } */ -void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) { +void *RM_GetSharedAPI(RedictModuleCtx *ctx, const char *apiname) { dictEntry *de = dictFind(server.sharedapi, apiname); if (de == NULL) return NULL; - RedisModuleSharedAPI *sapi = dictGetVal(de); + RedictModuleSharedAPI *sapi = dictGetVal(de); if (listSearchKey(sapi->module->usedby,ctx->module) == NULL) { listAddNodeTail(sapi->module->usedby,ctx->module); listAddNodeTail(ctx->module->using,sapi->module); @@ -10628,13 +10628,13 @@ void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) { * used by other modules. * * The number of unregistered APIs is returned. */ -int moduleUnregisterSharedAPI(RedisModule *module) { +int moduleUnregisterSharedAPI(RedictModule *module) { int count = 0; dictIterator *di = dictGetSafeIterator(server.sharedapi); dictEntry *de; while ((de = dictNext(di)) != NULL) { const char *apiname = dictGetKey(de); - RedisModuleSharedAPI *sapi = dictGetVal(de); + RedictModuleSharedAPI *sapi = dictGetVal(de); if (sapi->module == module) { dictDelete(server.sharedapi,apiname); zfree(sapi); @@ -10649,14 +10649,14 @@ int moduleUnregisterSharedAPI(RedisModule *module) { * This is usually called when a module is unloaded. * * Returns the number of modules this module was using APIs from. */ -int moduleUnregisterUsedAPI(RedisModule *module) { +int moduleUnregisterUsedAPI(RedictModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->using,&li); while((ln = listNext(&li))) { - RedisModule *used = ln->value; + RedictModule *used = ln->value; listNode *ln = listSearchKey(used->usedby,module); if (ln) { listDelNode(used->usedby,ln); @@ -10670,14 +10670,14 @@ int moduleUnregisterUsedAPI(RedisModule *module) { * This is called when a module is being unloaded. * * Returns the number of filters unregistered. */ -int moduleUnregisterFilters(RedisModule *module) { +int moduleUnregisterFilters(RedictModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->filters,&li); while((ln = listNext(&li))) { - RedisModuleCommandFilter *filter = ln->value; + RedictModuleCommandFilter *filter = ln->value; listNode *ln = listSearchKey(moduleCommandFilters,filter); if (ln) { listDelNode(moduleCommandFilters,ln); @@ -10702,18 +10702,18 @@ int moduleUnregisterFilters(RedisModule *module) { * filter applies in all execution paths including: * * 1. Invocation by a client. - * 2. Invocation through `RedisModule_Call()` by any module. + * 2. Invocation through `RedictModule_Call()` by any module. * 3. Invocation through Lua `redis.call()`. * 4. Replication of a command from a master. * * The filter executes in a special filter context, which is different and more - * limited than a RedisModuleCtx. Because the filter affects any command, it + * limited than a RedictModuleCtx. Because the filter affects any command, it * must be implemented in a very efficient way to reduce the performance impact * on Redis. All Redis Module API calls that require a valid context (such as - * `RedisModule_Call()`, `RedisModule_OpenKey()`, etc.) are not supported in a + * `RedictModule_Call()`, `RedictModule_OpenKey()`, etc.) are not supported in a * filter context. * - * The `RedisModuleCommandFilterCtx` can be used to inspect or modify the + * The `RedictModuleCommandFilterCtx` can be used to inspect or modify the * executed command and its arguments. As the filter executes before Redis * begins processing the command, any change will affect the way the command is * processed. For example, a module can override Redis commands this way: @@ -10727,7 +10727,7 @@ int moduleUnregisterFilters(RedisModule *module) { * and therefore executes the module's own command. * * Note that in the above use case, if `MODULE.SET` itself uses - * `RedisModule_Call()` the filter will be applied on that call as well. If + * `RedictModule_Call()` the filter will be applied on that call as well. If * that is not desired, the `REDISMODULE_CMDFILTER_NOSELF` flag can be set when * registering the filter. * @@ -10743,8 +10743,8 @@ int moduleUnregisterFilters(RedisModule *module) { * If multiple filters are registered (by the same or different modules), they * are executed in the order of registration. */ -RedisModuleCommandFilter *RM_RegisterCommandFilter(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc callback, int flags) { - RedisModuleCommandFilter *filter = zmalloc(sizeof(*filter)); +RedictModuleCommandFilter *RM_RegisterCommandFilter(RedictModuleCtx *ctx, RedictModuleCommandFilterFunc callback, int flags) { + RedictModuleCommandFilter *filter = zmalloc(sizeof(*filter)); filter->module = ctx->module; filter->callback = callback; filter->flags = flags; @@ -10756,7 +10756,7 @@ RedisModuleCommandFilter *RM_RegisterCommandFilter(RedisModuleCtx *ctx, RedisMod /* Unregister a command filter. */ -int RM_UnregisterCommandFilter(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) { +int RM_UnregisterCommandFilter(RedictModuleCtx *ctx, RedictModuleCommandFilter *filter) { listNode *ln; /* A module can only remove its own filters */ @@ -10782,7 +10782,7 @@ void moduleCallCommandFilters(client *c) { listNode *ln; listRewind(moduleCommandFilters,&li); - RedisModuleCommandFilterCtx filter = { + RedictModuleCommandFilterCtx filter = { .argv = c->argv, .argv_len = c->argv_len, .argc = c->argc, @@ -10790,7 +10790,7 @@ void moduleCallCommandFilters(client *c) { }; while((ln = listNext(&li))) { - RedisModuleCommandFilter *f = ln->value; + RedictModuleCommandFilter *f = ln->value; /* Skip filter if REDISMODULE_CMDFILTER_NOSELF is set and module is * currently processing a command. @@ -10809,7 +10809,7 @@ void moduleCallCommandFilters(client *c) { /* Return the number of arguments a filtered command has. The number of * arguments include the command itself. */ -int RM_CommandFilterArgsCount(RedisModuleCommandFilterCtx *fctx) +int RM_CommandFilterArgsCount(RedictModuleCommandFilterCtx *fctx) { return fctx->argc; } @@ -10817,18 +10817,18 @@ int RM_CommandFilterArgsCount(RedisModuleCommandFilterCtx *fctx) /* Return the specified command argument. The first argument (position 0) is * the command itself, and the rest are user-provided args. */ -RedisModuleString *RM_CommandFilterArgGet(RedisModuleCommandFilterCtx *fctx, int pos) +RedictModuleString *RM_CommandFilterArgGet(RedictModuleCommandFilterCtx *fctx, int pos) { if (pos < 0 || pos >= fctx->argc) return NULL; return fctx->argv[pos]; } /* Modify the filtered command by inserting a new argument at the specified - * position. The specified RedisModuleString argument may be used by Redis + * position. The specified RedictModuleString argument may be used by Redis * after the filter context is destroyed, so it must not be auto-memory * allocated, freed or used elsewhere. */ -int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) +int RM_CommandFilterArgInsert(RedictModuleCommandFilterCtx *fctx, int pos, RedictModuleString *arg) { int i; @@ -10836,7 +10836,7 @@ int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisM if (fctx->argv_len < fctx->argc+1) { fctx->argv_len = fctx->argc+1; - fctx->argv = zrealloc(fctx->argv, fctx->argv_len*sizeof(RedisModuleString *)); + fctx->argv = zrealloc(fctx->argv, fctx->argv_len*sizeof(RedictModuleString *)); } for (i = fctx->argc; i > pos; i--) { fctx->argv[i] = fctx->argv[i-1]; @@ -10848,11 +10848,11 @@ int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisM } /* Modify the filtered command by replacing an existing argument with a new one. - * The specified RedisModuleString argument may be used by Redis after the + * The specified RedictModuleString argument may be used by Redis after the * filter context is destroyed, so it must not be auto-memory allocated, freed * or used elsewhere. */ -int RM_CommandFilterArgReplace(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) +int RM_CommandFilterArgReplace(RedictModuleCommandFilterCtx *fctx, int pos, RedictModuleString *arg) { if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; @@ -10865,7 +10865,7 @@ int RM_CommandFilterArgReplace(RedisModuleCommandFilterCtx *fctx, int pos, Redis /* Modify the filtered command by deleting an argument at the specified * position. */ -int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) +int RM_CommandFilterArgDelete(RedictModuleCommandFilterCtx *fctx, int pos) { int i; if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; @@ -10880,12 +10880,12 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) } /* Get Client ID for client that issued the command we are filtering */ -unsigned long long RM_CommandFilterGetClientId(RedisModuleCommandFilterCtx *fctx) { +unsigned long long RM_CommandFilterGetClientId(RedictModuleCommandFilterCtx *fctx) { return fctx->c->id; } -/* For a given pointer allocated via RedisModule_Alloc() or - * RedisModule_Realloc(), return the amount of memory allocated for it. +/* For a given pointer allocated via RedictModule_Alloc() or + * RedictModule_Realloc(), return the amount of memory allocated for it. * Note that this may be different (larger) than the memory we allocated * with the allocation calls, since sometimes the underlying allocator * will allocate more memory. @@ -10903,19 +10903,19 @@ size_t RM_MallocUsableSize(void *ptr) { return zmalloc_usable_size(ptr); } -/* Same as RM_MallocSize, except it works on RedisModuleString pointers. +/* Same as RM_MallocSize, except it works on RedictModuleString pointers. */ -size_t RM_MallocSizeString(RedisModuleString* str) { +size_t RM_MallocSizeString(RedictModuleString* str) { serverAssert(str->type == OBJ_STRING); return sizeof(*str) + getStringObjectSdsUsedMemory(str); } -/* Same as RM_MallocSize, except it works on RedisModuleDict pointers. +/* Same as RM_MallocSize, except it works on RedictModuleDict pointers. * Note that the returned value is only the overhead of the underlying structures, * it does not include the allocation size of the keys and values. */ -size_t RM_MallocSizeDict(RedisModuleDict* dict) { - size_t size = sizeof(RedisModuleDict) + sizeof(rax); +size_t RM_MallocSizeDict(RedictModuleDict* dict) { + size_t size = sizeof(RedictModuleDict) + sizeof(rax); size += dict->rax->numnodes * sizeof(raxNode); /* For more info about this weird line, see streamRadixTreeMemoryUsage */ size += dict->rax->numnodes * sizeof(long)*30; @@ -10940,26 +10940,26 @@ float RM_GetUsedMemoryRatio(void){ * ## Scanning keyspace and hashes * -------------------------------------------------------------------------- */ -typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); +typedef void (*RedictModuleScanCB)(RedictModuleCtx *ctx, RedictModuleString *keyname, RedictModuleKey *key, void *privdata); typedef struct { - RedisModuleCtx *ctx; + RedictModuleCtx *ctx; void* user_data; - RedisModuleScanCB fn; + RedictModuleScanCB fn; } ScanCBData; -typedef struct RedisModuleScanCursor{ +typedef struct RedictModuleScanCursor{ unsigned long long cursor; int done; -}RedisModuleScanCursor; +}RedictModuleScanCursor; static void moduleScanCallback(void *privdata, const dictEntry *de) { ScanCBData *data = privdata; sds key = dictGetKey(de); robj* val = dictGetVal(de); - RedisModuleString *keyname = createObject(OBJ_STRING,sdsdup(key)); + RedictModuleString *keyname = createObject(OBJ_STRING,sdsdup(key)); /* Setup the key handle. */ - RedisModuleKey kp = {0}; + RedictModuleKey kp = {0}; moduleInitKey(&kp, data->ctx, keyname, val, REDISMODULE_READ); data->fn(data->ctx, keyname, &kp, data->user_data); @@ -10968,22 +10968,22 @@ static void moduleScanCallback(void *privdata, const dictEntry *de) { decrRefCount(keyname); } -/* Create a new cursor to be used with RedisModule_Scan */ -RedisModuleScanCursor *RM_ScanCursorCreate(void) { - RedisModuleScanCursor* cursor = zmalloc(sizeof(*cursor)); +/* Create a new cursor to be used with RedictModule_Scan */ +RedictModuleScanCursor *RM_ScanCursorCreate(void) { + RedictModuleScanCursor* cursor = zmalloc(sizeof(*cursor)); cursor->cursor = 0; cursor->done = 0; return cursor; } /* Restart an existing cursor. The keys will be rescanned. */ -void RM_ScanCursorRestart(RedisModuleScanCursor *cursor) { +void RM_ScanCursorRestart(RedictModuleScanCursor *cursor) { cursor->cursor = 0; cursor->done = 0; } /* Destroy the cursor struct. */ -void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { +void RM_ScanCursorDestroy(RedictModuleScanCursor *cursor) { zfree(cursor); } @@ -10992,36 +10992,36 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { * * Callback for scan implementation. * - * void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname, - * RedisModuleKey *key, void *privdata); + * void scan_callback(RedictModuleCtx *ctx, RedictModuleString *keyname, + * RedictModuleKey *key, void *privdata); * * - `ctx`: the redis module context provided to for the scan. * - `keyname`: owned by the caller and need to be retained if used after this * function. * - `key`: holds info on the key and value, it is provided as best effort, in * some cases it might be NULL, in which case the user should (can) use - * RedisModule_OpenKey() (and CloseKey too). + * RedictModule_OpenKey() (and CloseKey too). * when it is provided, it is owned by the caller and will be free when the * callback returns. - * - `privdata`: the user data provided to RedisModule_Scan(). + * - `privdata`: the user data provided to RedictModule_Scan(). * * The way it should be used: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * while(RedisModule_Scan(ctx, c, callback, privateData)); - * RedisModule_ScanCursorDestroy(c); + * RedictModuleScanCursor *c = RedictModule_ScanCursorCreate(); + * while(RedictModule_Scan(ctx, c, callback, privateData)); + * RedictModule_ScanCursorDestroy(c); * * It is also possible to use this API from another thread while the lock * is acquired during the actual call to RM_Scan: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModule_ThreadSafeContextLock(ctx); - * while(RedisModule_Scan(ctx, c, callback, privateData)){ - * RedisModule_ThreadSafeContextUnlock(ctx); + * RedictModuleScanCursor *c = RedictModule_ScanCursorCreate(); + * RedictModule_ThreadSafeContextLock(ctx); + * while(RedictModule_Scan(ctx, c, callback, privateData)){ + * RedictModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); + * RedictModule_ThreadSafeContextLock(ctx); * } - * RedisModule_ScanCursorDestroy(c); + * RedictModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and * 0 otherwise, possibly setting errno if the call failed. @@ -11043,7 +11043,7 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { * later when the iteration is complete. However this can cost a lot of * memory, so it may make sense to just operate on the current key when * possible during the iteration, given that this is safe. */ -int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) { +int RM_Scan(RedictModuleCtx *ctx, RedictModuleScanCursor *cursor, RedictModuleScanCB fn, void *privdata) { if (cursor->done) { errno = ENOENT; return 0; @@ -11059,11 +11059,11 @@ int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanC return ret; } -typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); +typedef void (*RedictModuleScanKeyCB)(RedictModuleKey *key, RedictModuleString *field, RedictModuleString *value, void *privdata); typedef struct { - RedisModuleKey *key; + RedictModuleKey *key; void* user_data; - RedisModuleScanKeyCB fn; + RedictModuleScanKeyCB fn; } ScanKeyCBData; static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { @@ -11091,38 +11091,38 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { * * Callback for scan implementation. * - * void scan_callback(RedisModuleKey *key, RedisModuleString* field, RedisModuleString* value, void *privdata); + * void scan_callback(RedictModuleKey *key, RedictModuleString* field, RedictModuleString* value, void *privdata); * * - key - the redis key context provided to for the scan. * - field - field name, owned by the caller and need to be retained if used * after this function. * - value - value string or NULL for set type, owned by the caller and need to * be retained if used after this function. - * - privdata - the user data provided to RedisModule_ScanKey. + * - privdata - the user data provided to RedictModule_ScanKey. * * The way it should be used: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModuleKey *key = RedisModule_OpenKey(...) - * while(RedisModule_ScanKey(key, c, callback, privateData)); - * RedisModule_CloseKey(key); - * RedisModule_ScanCursorDestroy(c); + * RedictModuleScanCursor *c = RedictModule_ScanCursorCreate(); + * RedictModuleKey *key = RedictModule_OpenKey(...) + * while(RedictModule_ScanKey(key, c, callback, privateData)); + * RedictModule_CloseKey(key); + * RedictModule_ScanCursorDestroy(c); * * It is also possible to use this API from another thread while the lock is acquired during * the actual call to RM_ScanKey, and re-opening the key each time: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModule_ThreadSafeContextLock(ctx); - * RedisModuleKey *key = RedisModule_OpenKey(...) - * while(RedisModule_ScanKey(ctx, c, callback, privateData)){ - * RedisModule_CloseKey(key); - * RedisModule_ThreadSafeContextUnlock(ctx); + * RedictModuleScanCursor *c = RedictModule_ScanCursorCreate(); + * RedictModule_ThreadSafeContextLock(ctx); + * RedictModuleKey *key = RedictModule_OpenKey(...) + * while(RedictModule_ScanKey(ctx, c, callback, privateData)){ + * RedictModule_CloseKey(key); + * RedictModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); - * RedisModuleKey *key = RedisModule_OpenKey(...) + * RedictModule_ThreadSafeContextLock(ctx); + * RedictModuleKey *key = RedictModule_OpenKey(...) * } - * RedisModule_CloseKey(key); - * RedisModule_ScanCursorDestroy(c); + * RedictModule_CloseKey(key); + * RedictModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and 0 otherwise, * possibly setting errno if the call failed. @@ -11135,7 +11135,7 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { * you play with the elements, the more duplicates you may get. In general * deleting the current element of the data structure is safe, while removing * the key you are iterating is not safe. */ -int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleScanKeyCB fn, void *privdata) { +int RM_ScanKey(RedictModuleKey *key, RedictModuleScanCursor *cursor, RedictModuleScanKeyCB fn, void *privdata) { if (key == NULL || key->value == NULL) { errno = EINVAL; return 0; @@ -11216,14 +11216,14 @@ int RM_ScanKey(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleSc * main process where you can do some processing in the background without * affecting / freezing the traffic and no need for threads and GIL locking. * Note that Redis allows for only one concurrent fork. - * When the child wants to exit, it should call RedisModule_ExitFromChild. - * If the parent wants to kill the child it should call RedisModule_KillForkChild + * When the child wants to exit, it should call RedictModule_ExitFromChild. + * If the parent wants to kill the child it should call RedictModule_KillForkChild * The done handler callback will be executed on the parent process when the * child existed (but not when killed) * Return: -1 on failure, on success the parent process will get a positive PID * of the child, and the child process will get 0. */ -int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { +int RM_Fork(RedictModuleForkDoneHandler cb, void *user_data) { pid_t childpid; if ((childpid = redictFork(CHILD_TYPE_MODULE)) == 0) { @@ -11280,7 +11280,7 @@ int TerminateModuleForkChild(int child_pid, int wait) { } /* Can be used to kill the forked child process from the parent process. - * child_pid would be the return value of RedisModule_Fork. */ + * child_pid would be the return value of RedictModule_Fork. */ int RM_KillForkChild(int child_pid) { /* Kill module child, wait for child exit. */ if (TerminateModuleForkChild(child_pid,1) == C_OK) @@ -11309,7 +11309,7 @@ void ModuleForkDoneHandler(int exitcode, int bysignal) { /* This must be synced with REDISMODULE_EVENT_* * We use -1 (MAX_UINT64) to denote that this event doesn't have * a data structure associated with it. We use MAX_UINT64 on purpose, - * in order to pass the check in RedisModule_SubscribeToServerEvent. */ + * in order to pass the check in RedictModule_SubscribeToServerEvent. */ static uint64_t moduleEventVersions[] = { REDISMODULE_REPLICATIONINFO_VERSION, /* REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED */ -1, /* REDISMODULE_EVENT_PERSISTENCE */ @@ -11343,8 +11343,8 @@ static uint64_t moduleEventVersions[] = { * * The callback must be of this type: * - * int (*RedisModuleEventCallback)(RedisModuleCtx *ctx, - * RedisModuleEvent eid, + * int (*RedictModuleEventCallback)(RedictModuleCtx *ctx, + * RedictModuleEvent eid, * uint64_t subevent, * void *data); * @@ -11360,7 +11360,7 @@ static uint64_t moduleEventVersions[] = { * * Here is a list of events you can use as 'eid' and related sub events: * - * * RedisModuleEvent_ReplicationRoleChanged: + * * RedictModuleEvent_ReplicationRoleChanged: * * This event is called when the instance switches from master * to replica or the other way around, however the event is @@ -11373,7 +11373,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA` * * The 'data' field can be casted by the callback to a - * `RedisModuleReplicationInfo` structure with the following fields: + * `RedictModuleReplicationInfo` structure with the following fields: * * int master; // true if master, false if replica * char *masterhost; // master instance hostname for NOW_REPLICA @@ -11383,7 +11383,7 @@ static uint64_t moduleEventVersions[] = { * uint64_t repl1_offset; // Main replication offset * uint64_t repl2_offset; // Offset of replid2 validity * - * * RedisModuleEvent_Persistence + * * RedictModuleEvent_Persistence * * This event is called when RDB saving or AOF rewriting starts * and ends. The following sub events are available: @@ -11406,7 +11406,7 @@ static uint64_t moduleEventVersions[] = { * clients and commands. Also note that the AOF_START sub event may end * up saving RDB content in case of an AOF with rdb-preamble. * - * * RedisModuleEvent_FlushDB + * * RedictModuleEvent_FlushDB * * The FLUSHALL, FLUSHDB or an internal flush (for instance * because of replication, after the replica synchronization) @@ -11415,7 +11415,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_FLUSHDB_START` * * `REDISMODULE_SUBEVENT_FLUSHDB_END` * - * The data pointer can be casted to a RedisModuleFlushInfo + * The data pointer can be casted to a RedictModuleFlushInfo * structure with the following fields: * * int32_t async; // True if the flush is done in a thread. @@ -11430,7 +11430,7 @@ static uint64_t moduleEventVersions[] = { * allowing the callback to call DBSIZE or other operation on the * yet-to-free keyspace. * - * * RedisModuleEvent_Loading + * * RedictModuleEvent_Loading * * Called on loading operations: at startup when the server is * started, but also after a first synchronization when the @@ -11446,21 +11446,21 @@ static uint64_t moduleEventVersions[] = { * Note that AOF loading may start with an RDB data in case of * rdb-preamble, in which case you'll only receive an AOF_START event. * - * * RedisModuleEvent_ClientChange + * * RedictModuleEvent_ClientChange * * Called when a client connects or disconnects. - * The data pointer can be casted to a RedisModuleClientInfo - * structure, documented in RedisModule_GetClientInfoById(). + * The data pointer can be casted to a RedictModuleClientInfo + * structure, documented in RedictModule_GetClientInfoById(). * The following sub events are available: * * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED` * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED` * - * * RedisModuleEvent_Shutdown + * * RedictModuleEvent_Shutdown * * The server is shutting down. No subevents are available. * - * * RedisModuleEvent_ReplicaChange + * * RedictModuleEvent_ReplicaChange * * This event is called when the instance (that can be both a * master or a replica) get a new online replica, or lose a @@ -11474,7 +11474,7 @@ static uint64_t moduleEventVersions[] = { * of Redis will have an API in order to enumerate the replicas * connected and their state. * - * * RedisModuleEvent_CronLoop + * * RedictModuleEvent_CronLoop * * This event is called every time Redis calls the serverCron() * function in order to do certain bookkeeping. Modules that are @@ -11483,12 +11483,12 @@ static uint64_t moduleEventVersions[] = { * this changes depending on the "hz" configuration. * No sub events are available. * - * The data pointer can be casted to a RedisModuleCronLoop + * The data pointer can be casted to a RedictModuleCronLoop * structure with the following fields: * * int32_t hz; // Approximate number of events per second. * - * * RedisModuleEvent_MasterLinkChange + * * RedictModuleEvent_MasterLinkChange * * This is called for replicas in order to notify when the * replication link becomes functional (up) with our master, @@ -11500,7 +11500,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_MASTER_LINK_UP` * * `REDISMODULE_SUBEVENT_MASTER_LINK_DOWN` * - * * RedisModuleEvent_ModuleChange + * * RedictModuleEvent_ModuleChange * * This event is called when a new module is loaded or one is unloaded. * The following sub events are available: @@ -11508,13 +11508,13 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_MODULE_LOADED` * * `REDISMODULE_SUBEVENT_MODULE_UNLOADED` * - * The data pointer can be casted to a RedisModuleModuleChange + * The data pointer can be casted to a RedictModuleModuleChange * structure with the following fields: * * const char* module_name; // Name of module loaded or unloaded. * int32_t module_version; // Module version. * - * * RedisModuleEvent_LoadingProgress + * * RedictModuleEvent_LoadingProgress * * This event is called repeatedly called while an RDB or AOF file * is being loaded. @@ -11523,29 +11523,29 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB` * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF` * - * The data pointer can be casted to a RedisModuleLoadingProgress + * The data pointer can be casted to a RedictModuleLoadingProgress * structure with the following fields: * * int32_t hz; // Approximate number of events per second. * int32_t progress; // Approximate progress between 0 and 1024, * // or -1 if unknown. * - * * RedisModuleEvent_SwapDB + * * RedictModuleEvent_SwapDB * * This event is called when a SWAPDB command has been successfully * Executed. * For this event call currently there is no subevents available. * - * The data pointer can be casted to a RedisModuleSwapDbInfo + * The data pointer can be casted to a RedictModuleSwapDbInfo * structure with the following fields: * * int32_t dbnum_first; // Swap Db first dbnum * int32_t dbnum_second; // Swap Db second dbnum * - * * RedisModuleEvent_ReplBackup + * * RedictModuleEvent_ReplBackup * * WARNING: Replication Backup events are deprecated since Redis 7.0 and are never fired. - * See RedisModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events + * See RedictModuleEvent_ReplAsyncLoad for understanding how Async Replication Loading events * are now triggered when repl-diskless-load is set to swapdb. * * Called when repl-diskless-load config is set to swapdb, @@ -11559,7 +11559,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE` * * `REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD` * - * * RedisModuleEvent_ReplAsyncLoad + * * RedictModuleEvent_ReplAsyncLoad * * Called when repl-diskless-load config is set to swapdb and a replication with a master of same * data set history (matching replication ID) occurs. @@ -11572,7 +11572,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED` * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED` * - * * RedisModuleEvent_ForkChild + * * RedictModuleEvent_ForkChild * * Called when a fork child (AOFRW, RDBSAVE, module fork...) is born/dies * The following sub events are available: @@ -11580,7 +11580,7 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_FORK_CHILD_BORN` * * `REDISMODULE_SUBEVENT_FORK_CHILD_DIED` * - * * RedisModuleEvent_EventLoop + * * RedictModuleEvent_EventLoop * * Called on each event loop iteration, once just before the event loop goes * to sleep or just after it wakes up. @@ -11589,21 +11589,21 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP` * * `REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP` * - * * RedisModule_Event_Config + * * RedictModule_Event_Config * * Called when a configuration event happens * The following sub events are available: * * * `REDISMODULE_SUBEVENT_CONFIG_CHANGE` * - * The data pointer can be casted to a RedisModuleConfigChange + * The data pointer can be casted to a RedictModuleConfigChange * structure with the following fields: * * const char **config_names; // An array of C string pointers containing the * // name of each modified configuration item * uint32_t num_changes; // The number of elements in the config_names array * - * * RedisModule_Event_Key + * * RedictModule_Event_Key * * Called when a key is removed from the keyspace. We can't modify any key in * the event. @@ -11614,16 +11614,16 @@ static uint64_t moduleEventVersions[] = { * * `REDISMODULE_SUBEVENT_KEY_EVICTED` * * `REDISMODULE_SUBEVENT_KEY_OVERWRITTEN` * - * The data pointer can be casted to a RedisModuleKeyInfo + * The data pointer can be casted to a RedictModuleKeyInfo * structure with the following fields: * - * RedisModuleKey *key; // Key name + * RedictModuleKey *key; // Key name * * The function returns REDISMODULE_OK if the module was successfully subscribed * for the specified event. If the API is called from a wrong context or unsupported event * is given then REDISMODULE_ERR is returned. */ -int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback) { - RedisModuleEventListener *el; +int RM_SubscribeToServerEvent(RedictModuleCtx *ctx, RedictModuleEvent event, RedictModuleEventCallback callback) { + RedictModuleEventListener *el; /* Protect in case of calls from contexts without a module reference. */ if (ctx->module == NULL) return REDISMODULE_ERR; @@ -11633,7 +11633,7 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis /* Search an event matching this module and event ID. */ listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(RedictModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == ctx->module && el->event.id == event.id) @@ -11643,7 +11643,7 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis /* Modify or remove the event listener if we already had one. */ if (ln) { if (callback == NULL) { - listDelNode(RedisModule_EventListeners,ln); + listDelNode(RedictModule_EventListeners,ln); zfree(el); } else { el->callback = callback; /* Update the callback with the new one. */ @@ -11656,7 +11656,7 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis el->module = ctx->module; el->event = event; el->callback = callback; - listAddNodeTail(RedisModule_EventListeners,el); + listAddNodeTail(RedictModule_EventListeners,el); return REDISMODULE_OK; } @@ -11664,7 +11664,7 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis * For a given server event and subevent, return zero if the * subevent is not supported and non-zero otherwise. */ -int RM_IsSubEventSupported(RedisModuleEvent event, int64_t subevent) { +int RM_IsSubEventSupported(RedictModuleEvent event, int64_t subevent) { switch (event.id) { case REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED: return subevent < _REDISMODULE_EVENT_REPLROLECHANGED_NEXT; @@ -11708,7 +11708,7 @@ int RM_IsSubEventSupported(RedisModuleEvent event, int64_t subevent) { typedef struct KeyInfo { int32_t dbnum; - RedisModuleString *key; + RedictModuleString *key; robj *value; int mode; } KeyInfo; @@ -11724,15 +11724,15 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { /* Fast path to return ASAP if there is nothing to do, avoiding to * setup the iterator and so forth: we want this call to be extremely * cheap if there are no registered modules. */ - if (listLength(RedisModule_EventListeners) == 0) return; + if (listLength(RedictModule_EventListeners) == 0) return; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(RedictModule_EventListeners,&li); while((ln = listNext(&li))) { - RedisModuleEventListener *el = ln->value; + RedictModuleEventListener *el = ln->value; if (el->event.id == eid) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { /* In the case of client changes, we're pushing the real client * so the event handler can mutate it if needed. For example, @@ -11746,11 +11746,11 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { } void *moduledata = NULL; - RedisModuleClientInfoV1 civ1; - RedisModuleReplicationInfoV1 riv1; - RedisModuleModuleChangeV1 mcv1; - RedisModuleKey key; - RedisModuleKeyInfoV1 ki = {REDISMODULE_KEYINFO_VERSION, &key}; + RedictModuleClientInfoV1 civ1; + RedictModuleReplicationInfoV1 riv1; + RedictModuleModuleChangeV1 mcv1; + RedictModuleKey key; + RedictModuleKeyInfoV1 ki = {REDISMODULE_KEYINFO_VERSION, &key}; /* Event specific context and data pointer setup. */ if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { @@ -11761,11 +11761,11 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { moduledata = &riv1; } else if (eid == REDISMODULE_EVENT_FLUSHDB) { moduledata = data; - RedisModuleFlushInfoV1 *fi = data; + RedictModuleFlushInfoV1 *fi = data; if (fi->dbnum != -1) selectDb(ctx.client, fi->dbnum); } else if (eid == REDISMODULE_EVENT_MODULE_CHANGE) { - RedisModule *m = data; + RedictModule *m = data; if (m == el->module) { moduleFreeContext(&ctx); continue; @@ -11804,16 +11804,16 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { /* Remove all the listeners for this module: this is used before unloading * a module. */ -void moduleUnsubscribeAllServerEvents(RedisModule *module) { - RedisModuleEventListener *el; +void moduleUnsubscribeAllServerEvents(RedictModule *module) { + RedictModuleEventListener *el; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(RedictModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == module) { - listDelNode(RedisModule_EventListeners,ln); + listDelNode(RedictModule_EventListeners,ln); zfree(el); } } @@ -11827,7 +11827,7 @@ void processModuleLoadingProgressEvent(int is_aof) { int progress = -1; if (server.loading_total_bytes) progress = (server.loading_loaded_bytes<<10) / server.loading_total_bytes; - RedisModuleLoadingProgressV1 fi = {REDISMODULE_LOADING_PROGRESS_VERSION, + RedictModuleLoadingProgressV1 fi = {REDISMODULE_LOADING_PROGRESS_VERSION, server.hz, progress}; moduleFireServerEvent(REDISMODULE_EVENT_LOADING_PROGRESS, @@ -11860,7 +11860,7 @@ void moduleNotifyKeyUnlink(robj *key, robj *val, int dbid, int flags) { moduleType *mt = mv->type; /* We prefer to use the enhanced version. */ if (mt->unlink2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + RedictModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; mt->unlink2(&ctx,mv->value); } else if (mt->unlink != NULL) { mt->unlink(key,mv->value); @@ -11878,7 +11878,7 @@ size_t moduleGetFreeEffort(robj *key, robj *val, int dbid) { size_t effort = 1; /* We prefer to use the enhanced version. */ if (mt->free_effort2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + RedictModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; effort = mt->free_effort2(&ctx,mv->value); } else if (mt->free_effort != NULL) { effort = mt->free_effort(key,mv->value); @@ -11895,7 +11895,7 @@ size_t moduleGetMemUsage(robj *key, robj *val, size_t sample_size, int dbid) { size_t size = 0; /* We prefer to use the enhanced version. */ if (mt->mem_usage2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + RedictModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; size = mt->mem_usage2(&ctx, mv->value, sample_size); } else if (mt->mem_usage != NULL) { size = mt->mem_usage(mv->value); @@ -11935,7 +11935,7 @@ int moduleRegisterApi(const char *funcname, void *funcptr) { } #define REGISTER_API(name) \ - moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)RM_ ## name) + moduleRegisterApi("RedictModule_" #name, (void *)(unsigned long)RM_ ## name) /* Global initialization at Redis startup. */ void moduleRegisterCoreAPI(void); @@ -11991,7 +11991,7 @@ void moduleInitModulesSystem(void) { Timers = raxNew(); /* Setup the event listeners data structures. */ - RedisModule_EventListeners = listCreate(); + RedictModule_EventListeners = listCreate(); /* Making sure moduleEventVersions is synced with the number of events. */ serverAssert(sizeof(moduleEventVersions)/sizeof(moduleEventVersions[0]) == _REDISMODULE_EVENT_NEXT); @@ -12039,7 +12039,7 @@ void moduleLoadQueueEntryFree(struct moduleLoadQueueEntry *loadmod) { } /* Remove Module Configs from standardConfig array in config.c */ -void moduleRemoveConfigs(RedisModule *module) { +void moduleRemoveConfigs(RedictModule *module) { listIter li; listNode *ln; listRewind(module->module_configs, &li); @@ -12053,7 +12053,7 @@ void moduleRemoveConfigs(RedisModule *module) { } /* Remove ACL categories added by the module when it fails to load. */ -void moduleRemoveCateogires(RedisModule *module) { +void moduleRemoveCateogires(RedictModule *module) { if (module->num_acl_categories_added) { ACLCleanupCategoriesOnFailure(module->num_acl_categories_added); } @@ -12092,7 +12092,7 @@ void moduleLoadFromQueue(void) { } } -void moduleFreeModuleStructure(struct RedisModule *module) { +void moduleFreeModuleStructure(struct RedictModule *module) { listRelease(module->types); listRelease(module->filters); listRelease(module->usedby); @@ -12125,11 +12125,11 @@ void moduleFreeArgs(struct redictCommandArg *args, int num_args) { * Note that caller needs to handle the deletion of the command table dict, * and after that needs to free the command->fullname and the command itself. */ -int moduleFreeCommand(struct RedisModule *module, struct redictCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) +int moduleFreeCommand(struct RedictModule *module, struct redictCommand *cmd) { + if (cmd->proc != RedictModuleCommandDispatcher) return C_ERR; - RedisModuleCommand *cp = cmd->module_cmd; + RedictModuleCommand *cp = cmd->module_cmd; if (cp->module != module) return C_ERR; @@ -12179,7 +12179,7 @@ int moduleFreeCommand(struct RedisModule *module, struct redictCommand *cmd) { return C_OK; } -void moduleUnregisterCommands(struct RedisModule *module) { +void moduleUnregisterCommands(struct RedictModule *module) { /* Unregister all the commands registered by this module. */ dictIterator *di = dictGetSafeIterator(server.commands); dictEntry *de; @@ -12199,9 +12199,9 @@ void moduleUnregisterCommands(struct RedisModule *module) { /* We parse argv to add sds "NAME VALUE" pairs to the server.module_configs_queue list of configs. * We also increment the module_argv pointer to just after ARGS if there are args, otherwise * we set it to NULL */ -int parseLoadexArguments(RedisModuleString ***module_argv, int *module_argc) { +int parseLoadexArguments(RedictModuleString ***module_argv, int *module_argc) { int args_specified = 0; - RedisModuleString **argv = *module_argv; + RedictModuleString **argv = *module_argv; int argc = *module_argc; for (int i = 0; i < argc; i++) { char *arg_val = argv[i]->ptr; @@ -12238,7 +12238,7 @@ int parseLoadexArguments(RedisModuleString ***module_argv, int *module_argc) { } /* Unregister module-related things, called when moduleLoad fails or moduleUnload. */ -void moduleUnregisterCleanup(RedisModule *module) { +void moduleUnregisterCleanup(RedictModule *module) { moduleFreeAuthenticatedClients(module); moduleUnregisterCommands(module); moduleUnsubscribeNotifications(module); @@ -12270,15 +12270,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa serverLog(LL_WARNING, "Module %s failed to load: %s", path, dlerror()); return C_ERR; } - onload = (int (*)(void *, void **, int))(unsigned long) dlsym(handle,"RedisModule_OnLoad"); + onload = (int (*)(void *, void **, int))(unsigned long) dlsym(handle,"RedictModule_OnLoad"); if (onload == NULL) { dlclose(handle); serverLog(LL_WARNING, - "Module %s does not export RedisModule_OnLoad() " + "Module %s does not export RedictModule_OnLoad() " "symbol. Module not loaded.",path); return C_ERR; } - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, NULL, REDISMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ if (onload((void*)&ctx,module_argv,module_argc) == REDISMODULE_ERR) { serverLog(LL_WARNING, @@ -12344,7 +12344,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa * C_OK is returned, otherwise C_ERR is returned and errmsg is set * with an appropriate message. */ int moduleUnload(sds name, const char **errmsg) { - struct RedisModule *module = dictFetchValue(modules,name); + struct RedictModule *module = dictFetchValue(modules,name); if (module == NULL) { *errmsg = "no such module with that name"; @@ -12369,9 +12369,9 @@ int moduleUnload(sds name, const char **errmsg) { /* Give module a chance to clean up. */ int (*onunload)(void *); - onunload = (int (*)(void *))(unsigned long) dlsym(module->handle, "RedisModule_OnUnload"); + onunload = (int (*)(void *))(unsigned long) dlsym(module->handle, "RedictModule_OnUnload"); if (onunload) { - RedisModuleCtx ctx; + RedictModuleCtx ctx; moduleCreateContext(&ctx, module, REDISMODULE_CTX_TEMP_CLIENT); int unload_status = onunload((void*)&ctx); moduleFreeContext(&ctx); @@ -12431,7 +12431,7 @@ void addReplyLoadedModules(client *c) { addReplyArrayLen(c,dictSize(modules)); while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); sds path = module->loadmod->path; addReplyMapLen(c,4); addReplyBulkCString(c,"name"); @@ -12457,7 +12457,7 @@ sds genModulesInfoStringRenderModulesList(list *l) { listRewind(l,&li); sds output = sdsnew("["); while((ln = listNext(&li))) { - RedisModule *module = ln->value; + RedictModule *module = ln->value; output = sdscat(output,module->name); if (ln != listLast(l)) output = sdscat(output,"|"); @@ -12467,7 +12467,7 @@ sds genModulesInfoStringRenderModulesList(list *l) { } /* Helper for genModulesInfoString(): render module options as an SDS string. */ -sds genModulesInfoStringRenderModuleOptions(struct RedisModule *module) { +sds genModulesInfoStringRenderModuleOptions(struct RedictModule *module) { sds output = sdsnew("["); if (module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) output = sdscat(output,"handle-io-errors|"); @@ -12492,7 +12492,7 @@ sds genModulesInfoString(sds info) { while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); sds usedby = genModulesInfoStringRenderModulesList(module->usedby); sds using = genModulesInfoStringRenderModulesList(module->using); @@ -12515,7 +12515,7 @@ sds genModulesInfoString(sds info) { * -------------------------------------------------------------------------- */ /* Check if the configuration name is already registered */ -int isModuleConfigNameRegistered(RedisModule *module, const char *name) { +int isModuleConfigNameRegistered(RedictModule *module, const char *name) { listNode *match = listSearchKey(module->module_configs, (void *) name); return match != NULL; } @@ -12570,7 +12570,7 @@ int moduleVerifyResourceName(const char *name) { * config.c to call module set callbacks. */ #define CONFIG_ERR_SIZE 256 static char configerr[CONFIG_ERR_SIZE]; -static void propagateErrorString(RedisModuleString *err_in, const char **err) { +static void propagateErrorString(RedictModuleString *err_in, const char **err) { if (err_in) { redict_strlcpy(configerr, err_in->ptr, CONFIG_ERR_SIZE); decrRefCount(err_in); @@ -12579,15 +12579,15 @@ static void propagateErrorString(RedisModuleString *err_in, const char **err) { } int setModuleBoolConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + RedictModuleString *error = NULL; int return_code = config->set_fn.set_bool(config->name, val, config->privdata, &error); propagateErrorString(error, err); return return_code == REDISMODULE_OK ? 1 : 0; } int setModuleStringConfig(ModuleConfig *config, sds strval, const char **err) { - RedisModuleString *error = NULL; - RedisModuleString *new = createStringObject(strval, sdslen(strval)); + RedictModuleString *error = NULL; + RedictModuleString *new = createStringObject(strval, sdslen(strval)); int return_code = config->set_fn.set_string(config->name, new, config->privdata, &error); propagateErrorString(error, err); decrRefCount(new); @@ -12595,14 +12595,14 @@ int setModuleStringConfig(ModuleConfig *config, sds strval, const char **err) { } int setModuleEnumConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + RedictModuleString *error = NULL; int return_code = config->set_fn.set_enum(config->name, val, config->privdata, &error); propagateErrorString(error, err); return return_code == REDISMODULE_OK ? 1 : 0; } int setModuleNumericConfig(ModuleConfig *config, long long val, const char **err) { - RedisModuleString *error = NULL; + RedictModuleString *error = NULL; int return_code = config->set_fn.set_numeric(config->name, val, config->privdata, &error); propagateErrorString(error, err); return return_code == REDISMODULE_OK ? 1 : 0; @@ -12615,7 +12615,7 @@ int getModuleBoolConfig(ModuleConfig *module_config) { } sds getModuleStringConfig(ModuleConfig *module_config) { - RedisModuleString *val = module_config->get_fn.get_string(module_config->name, module_config->privdata); + RedictModuleString *val = module_config->get_fn.get_string(module_config->name, module_config->privdata); return val ? sdsdup(val->ptr) : NULL; } @@ -12629,7 +12629,7 @@ long long getModuleNumericConfig(ModuleConfig *module_config) { /* This function takes a module and a list of configs stored as sds NAME VALUE pairs. * It attempts to call set on each of these configs. */ -int loadModuleConfigs(RedisModule *module) { +int loadModuleConfigs(RedictModule *module) { listIter li; listNode *ln; const char *err = NULL; @@ -12682,8 +12682,8 @@ int moduleConfigApplyConfig(list *module_configs, const char **err, const char * listIter li; listNode *ln; ModuleConfig *module_config; - RedisModuleString *error = NULL; - RedisModuleCtx ctx; + RedictModuleString *error = NULL; + RedictModuleCtx ctx; listRewind(module_configs, &li); while ((ln = listNext(&li))) { @@ -12705,7 +12705,7 @@ int moduleConfigApplyConfig(list *module_configs, const char **err, const char * * -------------------------------------------------------------------------- */ /* Create a module config object. */ -ModuleConfig *createModuleConfig(const char *name, RedisModuleConfigApplyFunc apply_fn, void *privdata, RedisModule *module) { +ModuleConfig *createModuleConfig(const char *name, RedictModuleConfigApplyFunc apply_fn, void *privdata, RedictModule *module) { ModuleConfig *new_config = zmalloc(sizeof(ModuleConfig)); new_config->name = sdsnew(name); new_config->apply_fn = apply_fn; @@ -12714,7 +12714,7 @@ ModuleConfig *createModuleConfig(const char *name, RedisModuleConfigApplyFunc ap return new_config; } -int moduleConfigValidityCheck(RedisModule *module, const char *name, unsigned int flags, configType type) { +int moduleConfigValidityCheck(RedictModule *module, const char *name, unsigned int flags, configType type) { if (!module->onload) { errno = EBUSY; return REDISMODULE_ERR; @@ -12778,8 +12778,8 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * The `setfn` callback is expected to return REDISMODULE_OK when the value is successfully * applied. It can also return REDISMODULE_ERR if the value can't be applied, and the - * *err pointer can be set with a RedisModuleString error message to provide to the client. - * This RedisModuleString will be freed by redis after returning from the set callback. + * *err pointer can be set with a RedictModuleString error message to provide to the client. + * This RedictModuleString will be freed by redis after returning from the set callback. * * All configs are registered with a name, a type, a default value, private data that is made * available in the callbacks, as well as several flags that modify the behavior of the config. @@ -12804,32 +12804,32 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * Example implementation: * - * RedisModuleString *strval; + * RedictModuleString *strval; * int adjustable = 1; - * RedisModuleString *getStringConfigCommand(const char *name, void *privdata) { + * RedictModuleString *getStringConfigCommand(const char *name, void *privdata) { * return strval; * } * - * int setStringConfigCommand(const char *name, RedisModuleString *new, void *privdata, RedisModuleString **err) { + * int setStringConfigCommand(const char *name, RedictModuleString *new, void *privdata, RedictModuleString **err) { * if (adjustable) { - * RedisModule_Free(strval); - * RedisModule_RetainString(NULL, new); + * RedictModule_Free(strval); + * RedictModule_RetainString(NULL, new); * strval = new; * return REDISMODULE_OK; * } - * *err = RedisModule_CreateString(NULL, "Not adjustable.", 15); + * *err = RedictModule_CreateString(NULL, "Not adjustable.", 15); * return REDISMODULE_ERR; * } * ... - * RedisModule_RegisterStringConfig(ctx, "string", NULL, REDISMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); + * RedictModule_RegisterStringConfig(ctx, "string", NULL, REDISMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); * * If the registration fails, REDISMODULE_ERR is returned and one of the following * errno is set: - * * EBUSY: Registering the Config outside of RedisModule_OnLoad. + * * EBUSY: Registering the Config outside of RedictModule_OnLoad. * * EINVAL: The provided flags are invalid for the registration or the name of the config contains invalid characters. * * EALREADY: The provided configuration name is already used. */ -int RM_RegisterStringConfig(RedisModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedisModuleConfigGetStringFunc getfn, RedisModuleConfigSetStringFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; +int RM_RegisterStringConfig(RedictModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedictModuleConfigGetStringFunc getfn, RedictModuleConfigSetStringFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) { + RedictModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { return REDISMODULE_ERR; } @@ -12844,9 +12844,9 @@ int RM_RegisterStringConfig(RedisModuleCtx *ctx, const char *name, const char *d /* Create a bool config that server clients can interact with via the * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See - * RedisModule_RegisterStringConfig for detailed information about configs. */ -int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedisModuleConfigGetBoolFunc getfn, RedisModuleConfigSetBoolFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * RedictModule_RegisterStringConfig for detailed information about configs. */ +int RM_RegisterBoolConfig(RedictModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedictModuleConfigGetBoolFunc getfn, RedictModuleConfigSetBoolFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) { + RedictModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, BOOL_CONFIG)) { return REDISMODULE_ERR; } @@ -12881,15 +12881,15 @@ int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val * return REDISMODULE_OK; * } * ... - * RedisModule_RegisterEnumConfig(ctx, "enum", 0, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); + * RedictModule_RegisterEnumConfig(ctx, "enum", 0, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); * * Note that you can use REDISMODULE_CONFIG_BITFLAGS so that multiple enum string * can be combined into one integer as bit flags, in which case you may want to * sort your enums so that the preferred combinations are present first. * - * See RedisModule_RegisterStringConfig for detailed general information about configs. */ -int RM_RegisterEnumConfig(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedisModuleConfigGetEnumFunc getfn, RedisModuleConfigSetEnumFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * See RedictModule_RegisterStringConfig for detailed general information about configs. */ +int RM_RegisterEnumConfig(RedictModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedictModuleConfigGetEnumFunc getfn, RedictModuleConfigSetEnumFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) { + RedictModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, ENUM_CONFIG)) { return REDISMODULE_ERR; } @@ -12912,9 +12912,9 @@ int RM_RegisterEnumConfig(RedisModuleCtx *ctx, const char *name, int default_val /* * Create an integer config that server clients can interact with via the * `CONFIG SET`, `CONFIG GET`, and `CONFIG REWRITE` commands. See - * RedisModule_RegisterStringConfig for detailed information about configs. */ -int RM_RegisterNumericConfig(RedisModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedisModuleConfigGetNumericFunc getfn, RedisModuleConfigSetNumericFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) { - RedisModule *module = ctx->module; + * RedictModule_RegisterStringConfig for detailed information about configs. */ +int RM_RegisterNumericConfig(RedictModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedictModuleConfigGetNumericFunc getfn, RedictModuleConfigSetNumericFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) { + RedictModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { return REDISMODULE_ERR; } @@ -12929,15 +12929,15 @@ int RM_RegisterNumericConfig(RedisModuleCtx *ctx, const char *name, long long de } /* Applies all pending configurations on the module load. This should be called - * after all of the configurations have been registered for the module inside of RedisModule_OnLoad. - * This will return REDISMODULE_ERR if it is called outside RedisModule_OnLoad. + * after all of the configurations have been registered for the module inside of RedictModule_OnLoad. + * This will return REDISMODULE_ERR if it is called outside RedictModule_OnLoad. * This API needs to be called when configurations are provided in either `MODULE LOADEX` * or provided as startup arguments. */ -int RM_LoadConfigs(RedisModuleCtx *ctx) { +int RM_LoadConfigs(RedictModuleCtx *ctx) { if (!ctx || !ctx->module || !ctx->module->onload) { return REDISMODULE_ERR; } - RedisModule *module = ctx->module; + RedictModule *module = ctx->module; /* Load configs from conf file or arguments from loadex */ if (loadModuleConfigs(module)) return REDISMODULE_ERR; return REDISMODULE_OK; @@ -12949,28 +12949,28 @@ int RM_LoadConfigs(RedisModuleCtx *ctx) { #define REDISMODULE_RDB_STREAM_FILE 1 -typedef struct RedisModuleRdbStream { +typedef struct RedictModuleRdbStream { int type; union { char *filename; } data; -} RedisModuleRdbStream; +} RedictModuleRdbStream; /* Create a stream object to save/load RDB to/from a file. * - * This function returns a pointer to RedisModuleRdbStream which is owned + * This function returns a pointer to RedictModuleRdbStream which is owned * by the caller. It requires a call to RM_RdbStreamFree() to free * the object. */ -RedisModuleRdbStream *RM_RdbStreamCreateFromFile(const char *filename) { - RedisModuleRdbStream *stream = zmalloc(sizeof(*stream)); +RedictModuleRdbStream *RM_RdbStreamCreateFromFile(const char *filename) { + RedictModuleRdbStream *stream = zmalloc(sizeof(*stream)); stream->type = REDISMODULE_RDB_STREAM_FILE; stream->data.filename = zstrdup(filename); return stream; } /* Release an RDB stream object. */ -void RM_RdbStreamFree(RedisModuleRdbStream *stream) { +void RM_RdbStreamFree(RedictModuleRdbStream *stream) { switch (stream->type) { case REDISMODULE_RDB_STREAM_FILE: zfree(stream->data.filename); @@ -12992,11 +12992,11 @@ void RM_RdbStreamFree(RedisModuleRdbStream *stream) { * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbLoad(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * RedictModuleRdbStream *s = RedictModule_RdbStreamCreateFromFile("exp.rdb"); + * RedictModule_RdbLoad(ctx, s, 0); + * RedictModule_RdbStreamFree(s); */ -int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int RM_RdbLoad(RedictModuleCtx *ctx, RedictModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { @@ -13052,11 +13052,11 @@ int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbSave(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * RedictModuleRdbStream *s = RedictModule_RdbStreamCreateFromFile("exp.rdb"); + * RedictModule_RdbSave(ctx, s, 0); + * RedictModule_RdbStreamFree(s); */ -int RM_RdbSave(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int RM_RdbSave(RedictModuleCtx *ctx, RedictModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { @@ -13121,7 +13121,7 @@ NULL } /* If this is a loadex command we want to populate server.module_configs_queue with * sds NAME VALUE pairs. We also want to increment argv to just after ARGS, if supplied. */ - if (parseLoadexArguments((RedisModuleString ***) &argv, &argc) == REDISMODULE_OK && + if (parseLoadexArguments((RedictModuleString ***) &argv, &argc) == REDISMODULE_OK && moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK) addReply(c,shared.ok); else { @@ -13159,7 +13159,7 @@ size_t moduleCount(void) { /* Set the key last access time for LRU based eviction. not relevant if the * servers's maxmemory policy is LFU based. Value is idle time in milliseconds. * returns REDISMODULE_OK if the LRU was updated, REDISMODULE_ERR otherwise. */ -int RM_SetLRU(RedisModuleKey *key, mstime_t lru_idle) { +int RM_SetLRU(RedictModuleKey *key, mstime_t lru_idle) { if (!key->value) return REDISMODULE_ERR; if (objectSetLRUOrLFU(key->value, -1, lru_idle, lru_idle>=0 ? LRU_CLOCK() : 0, 1)) @@ -13171,7 +13171,7 @@ int RM_SetLRU(RedisModuleKey *key, mstime_t lru_idle) { * Value is idletime in milliseconds or -1 if the server's eviction policy is * LFU based. * returns REDISMODULE_OK if when key is valid. */ -int RM_GetLRU(RedisModuleKey *key, mstime_t *lru_idle) { +int RM_GetLRU(RedictModuleKey *key, mstime_t *lru_idle) { *lru_idle = -1; if (!key->value) return REDISMODULE_ERR; @@ -13186,7 +13186,7 @@ int RM_GetLRU(RedisModuleKey *key, mstime_t *lru_idle) { * The frequency is a logarithmic counter that provides an indication of * the access frequencyonly (must be <= 255). * returns REDISMODULE_OK if the LFU was updated, REDISMODULE_ERR otherwise. */ -int RM_SetLFU(RedisModuleKey *key, long long lfu_freq) { +int RM_SetLFU(RedictModuleKey *key, long long lfu_freq) { if (!key->value) return REDISMODULE_ERR; if (objectSetLRUOrLFU(key->value, lfu_freq, -1, 0, 1)) @@ -13197,7 +13197,7 @@ int RM_SetLFU(RedisModuleKey *key, long long lfu_freq) { /* Gets the key access frequency or -1 if the server's eviction policy is not * LFU based. * returns REDISMODULE_OK if when key is valid. */ -int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) { +int RM_GetLFU(RedictModuleKey *key, long long *lfu_freq) { *lfu_freq = -1; if (!key->value) return REDISMODULE_ERR; @@ -13272,7 +13272,7 @@ int RM_GetServerVersion(void) { /** * Return the current redict-server runtime value of REDISMODULE_TYPE_METHOD_VERSION. * You can use that when calling RM_CreateDataType to know which fields of - * RedisModuleTypeMethods are gonna be supported and which will be ignored. + * RedictModuleTypeMethods are gonna be supported and which will be ignored. */ int RM_GetTypeMethodVersion(void) { return REDISMODULE_TYPE_METHOD_VERSION; @@ -13295,7 +13295,7 @@ int RM_GetTypeMethodVersion(void) { * * If old_value is non-NULL, the old value is returned by reference. */ -int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_value, void **old_value) { +int RM_ModuleTypeReplaceValue(RedictModuleKey *key, moduleType *mt, void *new_value, void **old_value) { if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; if (!key->value || key->value->type != OBJ_MODULE) @@ -13332,7 +13332,7 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val * must explicitly call RM_Free() to free it, same as the out_flags pointer if * used. */ -int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) { +int *RM_GetCommandKeysWithFlags(RedictModuleCtx *ctx, RedictModuleString **argv, int argc, int *num_keys, int **out_flags) { UNUSED(ctx); struct redictCommand *cmd; int *res = NULL; @@ -13379,12 +13379,12 @@ int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, i } /* Identical to RM_GetCommandKeysWithFlags when flags are not needed. */ -int *RM_GetCommandKeys(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) { +int *RM_GetCommandKeys(RedictModuleCtx *ctx, RedictModuleString **argv, int argc, int *num_keys) { return RM_GetCommandKeysWithFlags(ctx, argv, argc, num_keys, NULL); } /* Return the name of the command currently running */ -const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { +const char *RM_GetCurrentCommandName(RedictModuleCtx *ctx) { if (!ctx || !ctx->client || !ctx->client->cmd) return NULL; @@ -13398,7 +13398,7 @@ const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { /* The defrag context, used to manage state during calls to the data type * defrag callback. */ -struct RedisModuleDefragCtx { +struct RedictModuleDefragCtx { long long int endtime; unsigned long *cursor; struct redictObject *key; /* Optional name of key processed, NULL when unknown. */ @@ -13408,7 +13408,7 @@ struct RedisModuleDefragCtx { /* Register a defrag callback for global data, i.e. anything that the module * may allocate that is not tied to a specific data type. */ -int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { +int RM_RegisterDefragFunc(RedictModuleCtx *ctx, RedictModuleDefragFunc cb) { ctx->module->defrag_cb = cb; return REDISMODULE_OK; } @@ -13427,7 +13427,7 @@ int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { * NOTE: Modules should consider the frequency in which this function is called, * so it generally makes sense to do small batches of work in between calls. */ -int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { +int RM_DefragShouldStop(RedictModuleDefragCtx *ctx) { return (ctx->endtime != 0 && ctx->endtime < ustime()); } @@ -13453,7 +13453,7 @@ int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { * a guarantee that concurrent defragmentation of multiple keys will * not be performed. */ -int RM_DefragCursorSet(RedisModuleDefragCtx *ctx, unsigned long cursor) { +int RM_DefragCursorSet(RedictModuleDefragCtx *ctx, unsigned long cursor) { if (!ctx->cursor) return REDISMODULE_ERR; @@ -13467,7 +13467,7 @@ int RM_DefragCursorSet(RedisModuleDefragCtx *ctx, unsigned long cursor) { * the cursor should be ignored. See RM_DefragCursorSet() for more details on * defrag cursors. */ -int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { +int RM_DefragCursorGet(RedictModuleDefragCtx *ctx, unsigned long *cursor) { if (!ctx->cursor) return REDISMODULE_ERR; @@ -13486,12 +13486,12 @@ int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { * of the old one and update any reference to the old pointer, which must not * be used again. */ -void *RM_DefragAlloc(RedisModuleDefragCtx *ctx, void *ptr) { +void *RM_DefragAlloc(RedictModuleDefragCtx *ctx, void *ptr) { UNUSED(ctx); return activeDefragAlloc(ptr); } -/* Defrag a RedisModuleString previously allocated by RM_Alloc, RM_Calloc, etc. +/* Defrag a RedictModuleString previously allocated by RM_Alloc, RM_Calloc, etc. * See RM_DefragAlloc() for more information on how the defragmentation process * works. * @@ -13501,7 +13501,7 @@ void *RM_DefragAlloc(RedisModuleDefragCtx *ctx, void *ptr) { * by the module, will end up with a single reference (because the reference * on the Redis side is dropped as soon as the command callback returns). */ -RedisModuleString *RM_DefragRedisModuleString(RedisModuleDefragCtx *ctx, RedisModuleString *str) { +RedictModuleString *RM_DefragRedictModuleString(RedictModuleDefragCtx *ctx, RedictModuleString *str) { UNUSED(ctx); return activeDefragStringOb(str); } @@ -13516,7 +13516,7 @@ int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long en moduleValue *mv = value->ptr; moduleType *mt = mv->type; - RedisModuleDefragCtx defrag_ctx = { endtime, cursor, key, dbid}; + RedictModuleDefragCtx defrag_ctx = { endtime, cursor, key, dbid}; /* Invoke callback. Note that the callback may be missing if the key has been * replaced with a different type since our last visit. @@ -13565,7 +13565,7 @@ int moduleDefragValue(robj *key, robj *value, int dbid) { return 0; /* Defrag later */ } - RedisModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; + RedictModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; mt->defrag(&defrag_ctx, key, &mv->value); return 1; } @@ -13576,10 +13576,10 @@ void moduleDefragGlobals(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct RedictModule *module = dictGetVal(de); if (!module->defrag_cb) continue; - RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; + RedictModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_cb(&defrag_ctx); } dictReleaseIterator(di); @@ -13588,14 +13588,14 @@ void moduleDefragGlobals(void) { /* Returns the name of the key currently being processed. * There is no guarantee that the key name is always available, so this may return NULL. */ -const RedisModuleString *RM_GetKeyNameFromDefragCtx(RedisModuleDefragCtx *ctx) { +const RedictModuleString *RM_GetKeyNameFromDefragCtx(RedictModuleDefragCtx *ctx) { return ctx->key; } /* Returns the database id of the key currently being processed. * There is no guarantee that this info is always available, so this may return -1. */ -int RM_GetDbIdFromDefragCtx(RedisModuleDefragCtx *ctx) { +int RM_GetDbIdFromDefragCtx(RedictModuleDefragCtx *ctx) { return ctx->dbid; } @@ -13943,7 +13943,7 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(GetTypeMethodVersion); REGISTER_API(RegisterDefragFunc); REGISTER_API(DefragAlloc); - REGISTER_API(DefragRedisModuleString); + REGISTER_API(DefragRedictModuleString); REGISTER_API(DefragShouldStop); REGISTER_API(DefragCursorSet); REGISTER_API(DefragCursorGet); diff --git a/src/modules/helloacl.c b/src/modules/helloacl.c index 54e7e9d37..04204bdf4 100644 --- a/src/modules/helloacl.c +++ b/src/modules/helloacl.c @@ -9,36 +9,36 @@ #include // A simple global user -static RedisModuleUser *global; +static RedictModuleUser *global; static uint64_t global_auth_client_id = 0; /* HELLOACL.REVOKE * Synchronously revoke access from a user. */ -int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RevokeCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); if (global_auth_client_id) { - RedisModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id); - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + RedictModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } else { - return RedisModule_ReplyWithError(ctx, "Global user currently not used"); + return RedictModule_ReplyWithError(ctx, "Global user currently not used"); } } /* HELLOACL.RESET * Synchronously delete and re-create a module user. */ -int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int ResetCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - RedisModule_FreeModuleUser(global); - global = RedisModule_CreateModuleUser("global"); - RedisModule_SetModuleUserACL(global, "allcommands"); - RedisModule_SetModuleUserACL(global, "allkeys"); - RedisModule_SetModuleUserACL(global, "on"); + RedictModule_FreeModuleUser(global); + global = RedictModule_CreateModuleUser("global"); + RedictModule_SetModuleUserACL(global, "allcommands"); + RedictModule_SetModuleUserACL(global, "allkeys"); + RedictModule_SetModuleUserACL(global, "on"); - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } /* Callback handler for user changes, use this to notify a module of @@ -51,77 +51,77 @@ void HelloACL_UserChanged(uint64_t client_id, void *privdata) { /* HELLOACL.AUTHGLOBAL * Synchronously assigns a module user to the current context. */ -int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int AuthGlobalCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); if (global_auth_client_id) { - return RedisModule_ReplyWithError(ctx, "Global user currently used"); + return RedictModule_ReplyWithError(ctx, "Global user currently used"); } - RedisModule_AuthenticateClientWithUser(ctx, global, HelloACL_UserChanged, NULL, &global_auth_client_id); + RedictModule_AuthenticateClientWithUser(ctx, global, HelloACL_UserChanged, NULL, &global_auth_client_id); - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } #define TIMEOUT_TIME 1000 /* Reply callback for auth command HELLOACL.AUTHASYNC */ -int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloACL_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); size_t length; - RedisModuleString *user_string = RedisModule_GetBlockedClientPrivateData(ctx); - const char *name = RedisModule_StringPtrLen(user_string, &length); + RedictModuleString *user_string = RedictModule_GetBlockedClientPrivateData(ctx); + const char *name = RedictModule_StringPtrLen(user_string, &length); - if (RedisModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) == + if (RedictModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) == REDISMODULE_ERR) { - return RedisModule_ReplyWithError(ctx, "Invalid Username or password"); + return RedictModule_ReplyWithError(ctx, "Invalid Username or password"); } - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } /* Timeout callback for auth command HELLOACL.AUTHASYNC */ -int HelloACL_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloACL_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - return RedisModule_ReplyWithSimpleString(ctx, "Request timedout"); + return RedictModule_ReplyWithSimpleString(ctx, "Request timedout"); } /* Private data frees data for HELLOACL.AUTHASYNC command. */ -void HelloACL_FreeData(RedisModuleCtx *ctx, void *privdata) { +void HelloACL_FreeData(RedictModuleCtx *ctx, void *privdata) { REDISMODULE_NOT_USED(ctx); - RedisModule_FreeString(NULL, privdata); + RedictModule_FreeString(NULL, privdata); } /* Background authentication can happen here. */ void *HelloACL_ThreadMain(void *args) { void **targs = args; - RedisModuleBlockedClient *bc = targs[0]; - RedisModuleString *user = targs[1]; - RedisModule_Free(targs); + RedictModuleBlockedClient *bc = targs[0]; + RedictModuleString *user = targs[1]; + RedictModule_Free(targs); - RedisModule_UnblockClient(bc,user); + RedictModule_UnblockClient(bc,user); return NULL; } /* HELLOACL.AUTHASYNC * Asynchronously assigns an ACL user to the current context. */ -int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); +int AuthAsyncCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 2) return RedictModule_WrongArity(ctx); pthread_t tid; - RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx, HelloACL_Reply, HelloACL_Timeout, HelloACL_FreeData, TIMEOUT_TIME); + RedictModuleBlockedClient *bc = RedictModule_BlockClient(ctx, HelloACL_Reply, HelloACL_Timeout, HelloACL_FreeData, TIMEOUT_TIME); - void **targs = RedisModule_Alloc(sizeof(void*)*2); + void **targs = RedictModule_Alloc(sizeof(void*)*2); targs[0] = bc; - targs[1] = RedisModule_CreateStringFromString(NULL, argv[1]); + targs[1] = RedictModule_CreateStringFromString(NULL, argv[1]); if (pthread_create(&tid, NULL, HelloACL_ThreadMain, targs) != 0) { - RedisModule_AbortBlock(bc); - return RedisModule_ReplyWithError(ctx, "-ERR Can't start thread"); + RedictModule_AbortBlock(bc); + return RedictModule_ReplyWithError(ctx, "-ERR Can't start thread"); } return REDISMODULE_OK; @@ -129,33 +129,33 @@ int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"helloacl.reset", + if (RedictModule_CreateCommand(ctx,"helloacl.reset", ResetCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"helloacl.revoke", + if (RedictModule_CreateCommand(ctx,"helloacl.revoke", RevokeCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"helloacl.authglobal", + if (RedictModule_CreateCommand(ctx,"helloacl.authglobal", AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"helloacl.authasync", + if (RedictModule_CreateCommand(ctx,"helloacl.authasync", AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - global = RedisModule_CreateModuleUser("global"); - RedisModule_SetModuleUserACL(global, "allcommands"); - RedisModule_SetModuleUserACL(global, "allkeys"); - RedisModule_SetModuleUserACL(global, "on"); + global = RedictModule_CreateModuleUser("global"); + RedictModule_SetModuleUserACL(global, "allcommands"); + RedictModule_SetModuleUserACL(global, "allkeys"); + RedictModule_SetModuleUserACL(global, "on"); global_auth_client_id = 0; diff --git a/src/modules/helloblock.c b/src/modules/helloblock.c index 01f46f8fa..9558ffc47 100644 --- a/src/modules/helloblock.c +++ b/src/modules/helloblock.c @@ -11,38 +11,38 @@ #include /* Reply callback for blocking command HELLO.BLOCK */ -int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloBlock_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - int *myint = RedisModule_GetBlockedClientPrivateData(ctx); - return RedisModule_ReplyWithLongLong(ctx,*myint); + int *myint = RedictModule_GetBlockedClientPrivateData(ctx); + return RedictModule_ReplyWithLongLong(ctx,*myint); } /* Timeout callback for blocking command HELLO.BLOCK */ -int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloBlock_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); + return RedictModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLO.BLOCK command. */ -void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { +void HelloBlock_FreeData(RedictModuleCtx *ctx, void *privdata) { REDISMODULE_NOT_USED(ctx); - RedisModule_Free(privdata); + RedictModule_Free(privdata); } /* The thread entry point that actually executes the blocking part * of the command HELLO.BLOCK. */ void *HelloBlock_ThreadMain(void *arg) { void **targ = arg; - RedisModuleBlockedClient *bc = targ[0]; + RedictModuleBlockedClient *bc = targ[0]; long long delay = (unsigned long)targ[1]; - RedisModule_Free(targ); + RedictModule_Free(targ); sleep(delay); - int *r = RedisModule_Alloc(sizeof(int)); + int *r = RedictModule_Alloc(sizeof(int)); *r = rand(); - RedisModule_UnblockClient(bc,r); + RedictModule_UnblockClient(bc,r); return NULL; } @@ -54,49 +54,49 @@ void *HelloBlock_ThreadMain(void *arg) { * signal the thread that the client disconnected, and sleep the specified * amount of seconds with a while loop calling sleep(1), so that once we * detect the client disconnection, we can terminate the thread ASAP. */ -void HelloBlock_Disconnected(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc) { - RedisModule_Log(ctx,"warning","Blocked client %p disconnected!", +void HelloBlock_Disconnected(RedictModuleCtx *ctx, RedictModuleBlockedClient *bc) { + RedictModule_Log(ctx,"warning","Blocked client %p disconnected!", (void*)bc); /* Here you should cleanup your state / threads, and if possible - * call RedisModule_UnblockClient(), or notify the thread that will + * call RedictModule_UnblockClient(), or notify the thread that will * call the function ASAP. */ } /* HELLO.BLOCK -- Block for seconds, then reply with * a random number. Timeout is the command timeout, so that you can test * what happens when the delay is greater than the timeout. */ -int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 3) return RedisModule_WrongArity(ctx); +int HelloBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 3) return RedictModule_WrongArity(ctx); long long delay; long long timeout; - if (RedisModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + if (RedictModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) { + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); } - if (RedisModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + if (RedictModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) { + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); } pthread_t tid; - RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout); + RedictModuleBlockedClient *bc = RedictModule_BlockClient(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout); /* Here we set a disconnection handler, however since this module will * block in sleep() in a thread, there is not much we can do in the * callback, so this is just to show you the API. */ - RedisModule_SetDisconnectCallback(bc,HelloBlock_Disconnected); + RedictModule_SetDisconnectCallback(bc,HelloBlock_Disconnected); /* Now that we setup a blocking client, we need to pass the control * to the thread. However we need to pass arguments to the thread: * the delay and a reference to the blocked client handle. */ - void **targ = RedisModule_Alloc(sizeof(void*)*2); + void **targ = RedictModule_Alloc(sizeof(void*)*2); targ[0] = bc; targ[1] = (void*)(unsigned long) delay; if (pthread_create(&tid,NULL,HelloBlock_ThreadMain,targ) != 0) { - RedisModule_AbortBlock(bc); - return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); + RedictModule_AbortBlock(bc); + return RedictModule_ReplyWithError(ctx,"-ERR Can't start thread"); } return REDISMODULE_OK; } @@ -109,40 +109,40 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * would be trivial just using any data structure implementing a dictionary * in order to filter the duplicated items. */ void *HelloKeys_ThreadMain(void *arg) { - RedisModuleBlockedClient *bc = arg; - RedisModuleCtx *ctx = RedisModule_GetThreadSafeContext(bc); + RedictModuleBlockedClient *bc = arg; + RedictModuleCtx *ctx = RedictModule_GetThreadSafeContext(bc); long long cursor = 0; size_t replylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); do { - RedisModule_ThreadSafeContextLock(ctx); - RedisModuleCallReply *reply = RedisModule_Call(ctx, + RedictModule_ThreadSafeContextLock(ctx); + RedictModuleCallReply *reply = RedictModule_Call(ctx, "SCAN","l",(long long)cursor); - RedisModule_ThreadSafeContextUnlock(ctx); + RedictModule_ThreadSafeContextUnlock(ctx); - RedisModuleCallReply *cr_cursor = - RedisModule_CallReplyArrayElement(reply,0); - RedisModuleCallReply *cr_keys = - RedisModule_CallReplyArrayElement(reply,1); + RedictModuleCallReply *cr_cursor = + RedictModule_CallReplyArrayElement(reply,0); + RedictModuleCallReply *cr_keys = + RedictModule_CallReplyArrayElement(reply,1); - RedisModuleString *s = RedisModule_CreateStringFromCallReply(cr_cursor); - RedisModule_StringToLongLong(s,&cursor); - RedisModule_FreeString(ctx,s); + RedictModuleString *s = RedictModule_CreateStringFromCallReply(cr_cursor); + RedictModule_StringToLongLong(s,&cursor); + RedictModule_FreeString(ctx,s); - size_t items = RedisModule_CallReplyLength(cr_keys); + size_t items = RedictModule_CallReplyLength(cr_keys); for (size_t j = 0; j < items; j++) { - RedisModuleCallReply *ele = - RedisModule_CallReplyArrayElement(cr_keys,j); - RedisModule_ReplyWithCallReply(ctx,ele); + RedictModuleCallReply *ele = + RedictModule_CallReplyArrayElement(cr_keys,j); + RedictModule_ReplyWithCallReply(ctx,ele); replylen++; } - RedisModule_FreeCallReply(reply); + RedictModule_FreeCallReply(reply); } while (cursor != 0); - RedisModule_ReplySetArrayLength(ctx,replylen); + RedictModule_ReplySetArrayLength(ctx,replylen); - RedisModule_FreeThreadSafeContext(ctx); - RedisModule_UnblockClient(bc,NULL); + RedictModule_FreeThreadSafeContext(ctx); + RedictModule_UnblockClient(bc,NULL); return NULL; } @@ -150,40 +150,40 @@ void *HelloKeys_ThreadMain(void *arg) { * the server. The keys do not represent a point-in-time state so only the keys * that were in the database from the start to the end are guaranteed to be * there. */ -int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloKeys_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); - if (argc != 1) return RedisModule_WrongArity(ctx); + if (argc != 1) return RedictModule_WrongArity(ctx); pthread_t tid; /* Note that when blocking the client we do not set any callback: no * timeout is possible since we passed '0', nor we need a reply callback * because we'll use the thread safe context to accumulate a reply. */ - RedisModuleBlockedClient *bc = RedisModule_BlockClient(ctx,NULL,NULL,NULL,0); + RedictModuleBlockedClient *bc = RedictModule_BlockClient(ctx,NULL,NULL,NULL,0); /* Now that we setup a blocking client, we need to pass the control * to the thread. However we need to pass arguments to the thread: * the reference to the blocked client handle. */ if (pthread_create(&tid,NULL,HelloKeys_ThreadMain,bc) != 0) { - RedisModule_AbortBlock(bc); - return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); + RedictModule_AbortBlock(bc); + return RedictModule_ReplyWithError(ctx,"-ERR Can't start thread"); } return REDISMODULE_OK; } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.block", + if (RedictModule_CreateCommand(ctx,"hello.block", HelloBlock_RedisCommand,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.keys", + if (RedictModule_CreateCommand(ctx,"hello.keys", HelloKeys_RedisCommand,"",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; diff --git a/src/modules/hellocluster.c b/src/modules/hellocluster.c index ba3f2c7ff..ae2f1150a 100644 --- a/src/modules/hellocluster.c +++ b/src/modules/hellocluster.c @@ -14,66 +14,66 @@ #define MSGTYPE_PONG 2 /* HELLOCLUSTER.PINGALL */ -int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int PingallCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3); - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + RedictModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } /* HELLOCLUSTER.LIST */ -int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int ListCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); size_t numnodes; - char **ids = RedisModule_GetClusterNodesList(ctx,&numnodes); + char **ids = RedictModule_GetClusterNodesList(ctx,&numnodes); if (ids == NULL) { - return RedisModule_ReplyWithError(ctx,"Cluster not enabled"); + return RedictModule_ReplyWithError(ctx,"Cluster not enabled"); } - RedisModule_ReplyWithArray(ctx,numnodes); + RedictModule_ReplyWithArray(ctx,numnodes); for (size_t j = 0; j < numnodes; j++) { int port; - RedisModule_GetClusterNodeInfo(ctx,ids[j],NULL,NULL,&port,NULL); - RedisModule_ReplyWithArray(ctx,2); - RedisModule_ReplyWithStringBuffer(ctx,ids[j],REDISMODULE_NODE_ID_LEN); - RedisModule_ReplyWithLongLong(ctx,port); + RedictModule_GetClusterNodeInfo(ctx,ids[j],NULL,NULL,&port,NULL); + RedictModule_ReplyWithArray(ctx,2); + RedictModule_ReplyWithStringBuffer(ctx,ids[j],REDISMODULE_NODE_ID_LEN); + RedictModule_ReplyWithLongLong(ctx,port); } - RedisModule_FreeClusterNodesList(ids); + RedictModule_FreeClusterNodesList(ids); return REDISMODULE_OK; } /* Callback for message MSGTYPE_PING */ -void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { - RedisModule_Log(ctx,"notice","PING (type %d) RECEIVED from %.*s: '%.*s'", +void PingReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { + RedictModule_Log(ctx,"notice","PING (type %d) RECEIVED from %.*s: '%.*s'", type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); - RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PONG,"Ohi!",4); - RedisModuleCallReply *reply = RedisModule_Call(ctx, "INCR", "c", "pings_received"); - RedisModule_FreeCallReply(reply); + RedictModule_SendClusterMessage(ctx,NULL,MSGTYPE_PONG,"Ohi!",4); + RedictModuleCallReply *reply = RedictModule_Call(ctx, "INCR", "c", "pings_received"); + RedictModule_FreeCallReply(reply); } /* Callback for message MSGTYPE_PONG. */ -void PongReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { - RedisModule_Log(ctx,"notice","PONG (type %d) RECEIVED from %.*s: '%.*s'", +void PongReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) { + RedictModule_Log(ctx,"notice","PONG (type %d) RECEIVED from %.*s: '%.*s'", type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellocluster.pingall", + if (RedictModule_CreateCommand(ctx,"hellocluster.pingall", PingallCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellocluster.list", + if (RedictModule_CreateCommand(ctx,"hellocluster.list", ListCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; @@ -83,10 +83,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) * variable. Normally you do that in order for the distributed system * you create as a module to have total freedom in the keyspace * manipulation. */ - RedisModule_SetClusterFlags(ctx,REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION); + RedictModule_SetClusterFlags(ctx,REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION); /* Register our handlers for different message types. */ - RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver); - RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver); + RedictModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver); + RedictModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver); return REDISMODULE_OK; } diff --git a/src/modules/hellodict.c b/src/modules/hellodict.c index 0ebceee11..def6a8a04 100644 --- a/src/modules/hellodict.c +++ b/src/modules/hellodict.c @@ -10,31 +10,31 @@ #include #include -static RedisModuleDict *Keyspace; +static RedictModuleDict *Keyspace; /* HELLODICT.SET * * Set the specified key to the specified value. */ -int cmd_SET(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 3) return RedisModule_WrongArity(ctx); - RedisModule_DictSet(Keyspace,argv[1],argv[2]); +int cmd_SET(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 3) return RedictModule_WrongArity(ctx); + RedictModule_DictSet(Keyspace,argv[1],argv[2]); /* We need to keep a reference to the value stored at the key, otherwise * it would be freed when this callback returns. */ - RedisModule_RetainString(NULL,argv[2]); - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + RedictModule_RetainString(NULL,argv[2]); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } /* HELLODICT.GET * * Return the value of the specified key, or a null reply if the key * is not defined. */ -int cmd_GET(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); - RedisModuleString *val = RedisModule_DictGet(Keyspace,argv[1],NULL); +int cmd_GET(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 2) return RedictModule_WrongArity(ctx); + RedictModuleString *val = RedictModule_DictGet(Keyspace,argv[1],NULL); if (val == NULL) { - return RedisModule_ReplyWithNull(ctx); + return RedictModule_ReplyWithNull(ctx); } else { - return RedisModule_ReplyWithString(ctx, val); + return RedictModule_ReplyWithString(ctx, val); } } @@ -42,61 +42,61 @@ int cmd_GET(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { * * Return a list of matching keys, lexicographically between startkey * and endkey. No more than 'count' items are emitted. */ -int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 4) return RedisModule_WrongArity(ctx); +int cmd_KEYRANGE(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 4) return RedictModule_WrongArity(ctx); /* Parse the count argument. */ long long count; - if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + if (RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) { + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); } /* Seek the iterator. */ - RedisModuleDictIter *iter = RedisModule_DictIteratorStart( + RedictModuleDictIter *iter = RedictModule_DictIteratorStart( Keyspace, ">=", argv[1]); /* Reply with the matching items. */ char *key; size_t keylen; long long replylen = 0; /* Keep track of the emitted array len. */ - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - while((key = RedisModule_DictNextC(iter,&keylen,NULL)) != NULL) { + RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + while((key = RedictModule_DictNextC(iter,&keylen,NULL)) != NULL) { if (replylen >= count) break; - if (RedisModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR) + if (RedictModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR) break; - RedisModule_ReplyWithStringBuffer(ctx,key,keylen); + RedictModule_ReplyWithStringBuffer(ctx,key,keylen); replylen++; } - RedisModule_ReplySetArrayLength(ctx,replylen); + RedictModule_ReplySetArrayLength(ctx,replylen); /* Cleanup. */ - RedisModule_DictIteratorStop(iter); + RedictModule_DictIteratorStop(iter); return REDISMODULE_OK; } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellodict.set", + if (RedictModule_CreateCommand(ctx,"hellodict.set", cmd_SET,"write deny-oom",1,1,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellodict.get", + if (RedictModule_CreateCommand(ctx,"hellodict.get", cmd_GET,"readonly",1,1,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellodict.keyrange", + if (RedictModule_CreateCommand(ctx,"hellodict.keyrange", cmd_KEYRANGE,"readonly",1,1,0) == REDISMODULE_ERR) return REDISMODULE_ERR; /* Create our global dictionary. Here we'll set our keys and values. */ - Keyspace = RedisModule_CreateDict(NULL); + Keyspace = RedictModule_CreateDict(NULL); return REDISMODULE_OK; } diff --git a/src/modules/hellohook.c b/src/modules/hellohook.c index 7aa00d59c..e9b98cfc4 100644 --- a/src/modules/hellohook.c +++ b/src/modules/hellohook.c @@ -11,32 +11,32 @@ #include /* Client state change callback. */ -void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) +void clientChangeCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, void *data) { REDISMODULE_NOT_USED(ctx); REDISMODULE_NOT_USED(e); - RedisModuleClientInfo *ci = data; + RedictModuleClientInfo *ci = data; printf("Client %s event for client #%llu %s:%d\n", (sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ? "connection" : "disconnection", (unsigned long long)ci->id,ci->addr,ci->port); } -void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) +void flushdbCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, void *data) { REDISMODULE_NOT_USED(ctx); REDISMODULE_NOT_USED(e); - RedisModuleFlushInfo *fi = data; + RedictModuleFlushInfo *fi = data; if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) { if (fi->dbnum != -1) { - RedisModuleCallReply *reply; - reply = RedisModule_Call(ctx,"DBSIZE",""); - long long numkeys = RedisModule_CallReplyInteger(reply); + RedictModuleCallReply *reply; + reply = RedictModule_Call(ctx,"DBSIZE",""); + long long numkeys = RedictModule_CallReplyInteger(reply); printf("FLUSHDB event of database %d started (%lld keys in DB)\n", fi->dbnum, numkeys); - RedisModule_FreeCallReply(reply); + RedictModule_FreeCallReply(reply); } else { printf("FLUSHALL event started\n"); } @@ -51,16 +51,16 @@ void flushdbCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - RedisModule_SubscribeToServerEvent(ctx, - RedisModuleEvent_ClientChange, clientChangeCallback); - RedisModule_SubscribeToServerEvent(ctx, - RedisModuleEvent_FlushDB, flushdbCallback); + RedictModule_SubscribeToServerEvent(ctx, + RedictModuleEvent_ClientChange, clientChangeCallback); + RedictModule_SubscribeToServerEvent(ctx, + RedictModuleEvent_FlushDB, flushdbCallback); return REDISMODULE_OK; } diff --git a/src/modules/hellotimer.c b/src/modules/hellotimer.c index f1a50f9fa..0bf9f28be 100644 --- a/src/modules/hellotimer.c +++ b/src/modules/hellotimer.c @@ -11,37 +11,37 @@ #include /* Timer callback. */ -void timerHandler(RedisModuleCtx *ctx, void *data) { +void timerHandler(RedictModuleCtx *ctx, void *data) { REDISMODULE_NOT_USED(ctx); printf("Fired %s!\n", (char *)data); - RedisModule_Free(data); + RedictModule_Free(data); } /* HELLOTIMER.TIMER*/ -int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int TimerCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); for (int j = 0; j < 10; j++) { int delay = rand() % 5000; - char *buf = RedisModule_Alloc(256); + char *buf = RedictModule_Alloc(256); snprintf(buf,256,"After %d", delay); - RedisModuleTimerID tid = RedisModule_CreateTimer(ctx,delay,timerHandler,buf); + RedictModuleTimerID tid = RedictModule_CreateTimer(ctx,delay,timerHandler,buf); REDISMODULE_NOT_USED(tid); } - return RedisModule_ReplyWithSimpleString(ctx, "OK"); + return RedictModule_ReplyWithSimpleString(ctx, "OK"); } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellotimer.timer", + if (RedictModule_CreateCommand(ctx,"hellotimer.timer", TimerCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; diff --git a/src/modules/hellotype.c b/src/modules/hellotype.c index eb47f41fd..8e28f582b 100644 --- a/src/modules/hellotype.c +++ b/src/modules/hellotype.c @@ -11,7 +11,7 @@ #include #include -static RedisModuleType *HelloType; +static RedictModuleType *HelloType; /* ========================== Internal data structure ======================= * This is just a linked list of 64 bit integers where elements are inserted @@ -31,7 +31,7 @@ struct HelloTypeObject { struct HelloTypeObject *createHelloTypeObject(void) { struct HelloTypeObject *o; - o = RedisModule_Alloc(sizeof(*o)); + o = RedictModule_Alloc(sizeof(*o)); o->head = NULL; o->len = 0; return o; @@ -44,7 +44,7 @@ void HelloTypeInsert(struct HelloTypeObject *o, int64_t ele) { prev = next; next = next->next; } - newnode = RedisModule_Alloc(sizeof(*newnode)); + newnode = RedictModule_Alloc(sizeof(*newnode)); newnode->value = ele; newnode->next = next; if (prev) { @@ -60,103 +60,103 @@ void HelloTypeReleaseObject(struct HelloTypeObject *o) { cur = o->head; while(cur) { next = cur->next; - RedisModule_Free(cur); + RedictModule_Free(cur); cur = next; } - RedisModule_Free(o); + RedictModule_Free(o); } /* ========================= "hellotype" type commands ======================= */ /* HELLOTYPE.INSERT key value */ -int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloTypeInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 3) return RedisModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + if (argc != 3) return RedictModule_WrongArity(ctx); + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int type = RedisModule_KeyType(key); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_EMPTY && - RedisModule_ModuleTypeGetType(key) != HelloType) + RedictModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } long long value; - if ((RedisModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) { - return RedisModule_ReplyWithError(ctx,"ERR invalid value: must be a signed 64 bit integer"); + if ((RedictModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) { + return RedictModule_ReplyWithError(ctx,"ERR invalid value: must be a signed 64 bit integer"); } /* Create an empty value object if the key is currently empty. */ struct HelloTypeObject *hto; if (type == REDISMODULE_KEYTYPE_EMPTY) { hto = createHelloTypeObject(); - RedisModule_ModuleTypeSetValue(key,HelloType,hto); + RedictModule_ModuleTypeSetValue(key,HelloType,hto); } else { - hto = RedisModule_ModuleTypeGetValue(key); + hto = RedictModule_ModuleTypeGetValue(key); } /* Insert the new element. */ HelloTypeInsert(hto,value); - RedisModule_SignalKeyAsReady(ctx,argv[1]); + RedictModule_SignalKeyAsReady(ctx,argv[1]); - RedisModule_ReplyWithLongLong(ctx,hto->len); - RedisModule_ReplicateVerbatim(ctx); + RedictModule_ReplyWithLongLong(ctx,hto->len); + RedictModule_ReplicateVerbatim(ctx); return REDISMODULE_OK; } /* HELLOTYPE.RANGE key first count */ -int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 4) return RedisModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + if (argc != 4) return RedictModule_WrongArity(ctx); + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int type = RedisModule_KeyType(key); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_EMPTY && - RedisModule_ModuleTypeGetType(key) != HelloType) + RedictModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } long long first, count; - if (RedisModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK || - RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK || + if (RedictModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK || + RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK || first < 0 || count < 0) { - return RedisModule_ReplyWithError(ctx, + return RedictModule_ReplyWithError(ctx, "ERR invalid first or count parameters"); } - struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); + struct HelloTypeObject *hto = RedictModule_ModuleTypeGetValue(key); struct HelloTypeNode *node = hto ? hto->head : NULL; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); long long arraylen = 0; while(node && count--) { - RedisModule_ReplyWithLongLong(ctx,node->value); + RedictModule_ReplyWithLongLong(ctx,node->value); arraylen++; node = node->next; } - RedisModule_ReplySetArrayLength(ctx,arraylen); + RedictModule_ReplySetArrayLength(ctx,arraylen); return REDISMODULE_OK; } /* HELLOTYPE.LEN key */ -int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloTypeLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 2) return RedisModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + if (argc != 2) return RedictModule_WrongArity(ctx); + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int type = RedisModule_KeyType(key); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_EMPTY && - RedisModule_ModuleTypeGetType(key) != HelloType) + RedictModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } - struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); - RedisModule_ReplyWithLongLong(ctx,hto ? hto->len : 0); + struct HelloTypeObject *hto = RedictModule_ModuleTypeGetValue(key); + RedictModule_ReplyWithLongLong(ctx,hto ? hto->len : 0); return REDISMODULE_OK; } @@ -165,59 +165,59 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int /* Reply callback for blocking command HELLOTYPE.BRANGE, this will get * called when the key we blocked for is ready: we need to check if we * can really serve the client, and reply OK or ERR accordingly. */ -int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloBlock_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - RedisModuleString *keyname = RedisModule_GetBlockedClientReadyKey(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,REDISMODULE_READ); - int type = RedisModule_KeyType(key); + RedictModuleString *keyname = RedictModule_GetBlockedClientReadyKey(ctx); + RedictModuleKey *key = RedictModule_OpenKey(ctx,keyname,REDISMODULE_READ); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_MODULE || - RedisModule_ModuleTypeGetType(key) != HelloType) + RedictModule_ModuleTypeGetType(key) != HelloType) { - RedisModule_CloseKey(key); + RedictModule_CloseKey(key); return REDISMODULE_ERR; } /* In case the key is able to serve our blocked client, let's directly * use our original command implementation to make this example simpler. */ - RedisModule_CloseKey(key); + RedictModule_CloseKey(key); return HelloTypeRange_RedisCommand(ctx,argv,argc-1); } /* Timeout callback for blocking command HELLOTYPE.BRANGE */ -int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloBlock_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); + return RedictModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLOTYPE.BRANGE command. */ -void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { +void HelloBlock_FreeData(RedictModuleCtx *ctx, void *privdata) { REDISMODULE_NOT_USED(ctx); - RedisModule_Free(privdata); + RedictModule_Free(privdata); } /* HELLOTYPE.BRANGE key first count timeout -- This is a blocking version of * the RANGE operation, in order to show how to use the API - * RedisModule_BlockClientOnKeys(). */ -int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 5) return RedisModule_WrongArity(ctx); - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + * RedictModule_BlockClientOnKeys(). */ +int HelloTypeBRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 5) return RedictModule_WrongArity(ctx); + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int type = RedisModule_KeyType(key); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_EMPTY && - RedisModule_ModuleTypeGetType(key) != HelloType) + RedictModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } /* Parse the timeout before even trying to serve the client synchronously, * so that we always fail ASAP on syntax errors. */ long long timeout; - if (RedisModule_StringToLongLong(argv[4],&timeout) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx, + if (RedictModule_StringToLongLong(argv[4],&timeout) != REDISMODULE_OK) { + return RedictModule_ReplyWithError(ctx, "ERR invalid timeout parameter"); } @@ -227,42 +227,42 @@ int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } /* Otherwise let's block on the key. */ - void *privdata = RedisModule_Alloc(100); - RedisModule_BlockClientOnKeys(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout,argv+1,1,privdata); + void *privdata = RedictModule_Alloc(100); + RedictModule_BlockClientOnKeys(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout,argv+1,1,privdata); return REDISMODULE_OK; } /* ========================== "hellotype" type methods ======================= */ -void *HelloTypeRdbLoad(RedisModuleIO *rdb, int encver) { +void *HelloTypeRdbLoad(RedictModuleIO *rdb, int encver) { if (encver != 0) { - /* RedisModule_Log("warning","Can't load data with version %d", encver);*/ + /* RedictModule_Log("warning","Can't load data with version %d", encver);*/ return NULL; } - uint64_t elements = RedisModule_LoadUnsigned(rdb); + uint64_t elements = RedictModule_LoadUnsigned(rdb); struct HelloTypeObject *hto = createHelloTypeObject(); while(elements--) { - int64_t ele = RedisModule_LoadSigned(rdb); + int64_t ele = RedictModule_LoadSigned(rdb); HelloTypeInsert(hto,ele); } return hto; } -void HelloTypeRdbSave(RedisModuleIO *rdb, void *value) { +void HelloTypeRdbSave(RedictModuleIO *rdb, void *value) { struct HelloTypeObject *hto = value; struct HelloTypeNode *node = hto->head; - RedisModule_SaveUnsigned(rdb,hto->len); + RedictModule_SaveUnsigned(rdb,hto->len); while(node) { - RedisModule_SaveSigned(rdb,node->value); + RedictModule_SaveSigned(rdb,node->value); node = node->next; } } -void HelloTypeAofRewrite(RedisModuleIO *aof, RedisModuleString *key, void *value) { +void HelloTypeAofRewrite(RedictModuleIO *aof, RedictModuleString *key, void *value) { struct HelloTypeObject *hto = value; struct HelloTypeNode *node = hto->head; while(node) { - RedisModule_EmitAOF(aof,"HELLOTYPE.INSERT","sl",key,node->value); + RedictModule_EmitAOF(aof,"HELLOTYPE.INSERT","sl",key,node->value); node = node->next; } } @@ -279,26 +279,26 @@ void HelloTypeFree(void *value) { HelloTypeReleaseObject(value); } -void HelloTypeDigest(RedisModuleDigest *md, void *value) { +void HelloTypeDigest(RedictModuleDigest *md, void *value) { struct HelloTypeObject *hto = value; struct HelloTypeNode *node = hto->head; while(node) { - RedisModule_DigestAddLongLong(md,node->value); + RedictModule_DigestAddLongLong(md,node->value); node = node->next; } - RedisModule_DigestEndSequence(md); + RedictModule_DigestEndSequence(md); } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1) + if (RedictModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - RedisModuleTypeMethods tm = { + RedictModuleTypeMethods tm = { .version = REDISMODULE_TYPE_METHOD_VERSION, .rdb_load = HelloTypeRdbLoad, .rdb_save = HelloTypeRdbSave, @@ -308,22 +308,22 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) .digest = HelloTypeDigest }; - HelloType = RedisModule_CreateDataType(ctx,"hellotype",0,&tm); + HelloType = RedictModule_CreateDataType(ctx,"hellotype",0,&tm); if (HelloType == NULL) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellotype.insert", + if (RedictModule_CreateCommand(ctx,"hellotype.insert", HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellotype.range", + if (RedictModule_CreateCommand(ctx,"hellotype.range", HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellotype.len", + if (RedictModule_CreateCommand(ctx,"hellotype.len", HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hellotype.brange", + if (RedictModule_CreateCommand(ctx,"hellotype.brange", HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index 76e9c8a59..09eeddeda 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -15,10 +15,10 @@ * missing in Redis. The command uses two important API calls: one to * fetch the currently selected DB, the other in order to send the client * an integer reply as response. */ -int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloSimple_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - RedisModule_ReplyWithLongLong(ctx,RedisModule_GetSelectedDb(ctx)); + RedictModule_ReplyWithLongLong(ctx,RedictModule_GetSelectedDb(ctx)); return REDISMODULE_OK; } @@ -28,17 +28,17 @@ int HelloSimple_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int * * You'll find this command to be roughly as fast as the actual RPUSH * command. */ -int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +int HelloPushNative_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { - if (argc != 3) return RedisModule_WrongArity(ctx); + if (argc != 3) return RedictModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - RedisModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]); - size_t newlen = RedisModule_ValueLength(key); - RedisModule_CloseKey(key); - RedisModule_ReplyWithLongLong(ctx,newlen); + RedictModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]); + size_t newlen = RedictModule_ValueLength(key); + RedictModule_CloseKey(key); + RedictModule_ReplyWithLongLong(ctx,newlen); return REDISMODULE_OK; } @@ -47,53 +47,53 @@ int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, * approach is useful when you need to call Redis commands that are not * available as low level APIs, or when you don't need the maximum speed * possible but instead prefer implementation simplicity. */ -int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +int HelloPushCall_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { - if (argc != 3) return RedisModule_WrongArity(ctx); + if (argc != 3) return RedictModule_WrongArity(ctx); - RedisModuleCallReply *reply; + RedictModuleCallReply *reply; - reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); - long long len = RedisModule_CallReplyInteger(reply); - RedisModule_FreeCallReply(reply); - RedisModule_ReplyWithLongLong(ctx,len); + reply = RedictModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); + long long len = RedictModule_CallReplyInteger(reply); + RedictModule_FreeCallReply(reply); + RedictModule_ReplyWithLongLong(ctx,len); return REDISMODULE_OK; } /* HELLO.PUSH.CALL2 * This is exactly as HELLO.PUSH.CALL, but shows how we can reply to the * client using directly a reply object that Call() returned. */ -int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +int HelloPushCall2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { - if (argc != 3) return RedisModule_WrongArity(ctx); + if (argc != 3) return RedictModule_WrongArity(ctx); - RedisModuleCallReply *reply; + RedictModuleCallReply *reply; - reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); - RedisModule_ReplyWithCallReply(ctx,reply); - RedisModule_FreeCallReply(reply); + reply = RedictModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); + RedictModule_ReplyWithCallReply(ctx,reply); + RedictModule_FreeCallReply(reply); return REDISMODULE_OK; } /* HELLO.LIST.SUM.LEN returns the total length of all the items inside * a Redis list, by using the high level Call() API. * This command is an example of the array reply access. */ -int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +int HelloListSumLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); + if (argc != 2) return RedictModule_WrongArity(ctx); - RedisModuleCallReply *reply; + RedictModuleCallReply *reply; - reply = RedisModule_Call(ctx,"LRANGE","sll",argv[1],(long long)0,(long long)-1); + reply = RedictModule_Call(ctx,"LRANGE","sll",argv[1],(long long)0,(long long)-1); size_t strlen = 0; - size_t items = RedisModule_CallReplyLength(reply); + size_t items = RedictModule_CallReplyLength(reply); size_t j; for (j = 0; j < items; j++) { - RedisModuleCallReply *ele = RedisModule_CallReplyArrayElement(reply,j); - strlen += RedisModule_CallReplyLength(ele); + RedictModuleCallReply *ele = RedictModule_CallReplyArrayElement(reply,j); + strlen += RedictModule_CallReplyLength(ele); } - RedisModule_FreeCallReply(reply); - RedisModule_ReplyWithLongLong(ctx,strlen); + RedictModule_FreeCallReply(reply); + RedictModule_ReplyWithLongLong(ctx,strlen); return REDISMODULE_OK; } @@ -101,117 +101,117 @@ int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, * Moves 'count' elements from the tail of 'srclist' to the head of * 'dstlist'. If less than count elements are available, it moves as much * elements as possible. */ -int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 4) return RedisModule_WrongArity(ctx); +int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 4) return RedictModule_WrongArity(ctx); - RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *srckey = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], + RedictModuleKey *dstkey = RedictModule_OpenKey(ctx,argv[2], REDISMODULE_READ|REDISMODULE_WRITE); /* Src and dst key must be empty or lists. */ - if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || - (RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) + if ((RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && + RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || + (RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && + RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) { - RedisModule_CloseKey(srckey); - RedisModule_CloseKey(dstkey); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + RedictModule_CloseKey(srckey); + RedictModule_CloseKey(dstkey); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || (count < 0)) { - RedisModule_CloseKey(srckey); - RedisModule_CloseKey(dstkey); - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + RedictModule_CloseKey(srckey); + RedictModule_CloseKey(dstkey); + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); } while(count-- > 0) { - RedisModuleString *ele; + RedictModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedictModule_ListPop(srckey,REDISMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); - RedisModule_FreeString(ctx,ele); + RedictModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedictModule_FreeString(ctx,ele); } - size_t len = RedisModule_ValueLength(srckey); - RedisModule_CloseKey(srckey); - RedisModule_CloseKey(dstkey); - RedisModule_ReplyWithLongLong(ctx,len); + size_t len = RedictModule_ValueLength(srckey); + RedictModule_CloseKey(srckey); + RedictModule_CloseKey(dstkey); + RedictModule_ReplyWithLongLong(ctx,len); return REDISMODULE_OK; } /* Like the HELLO.LIST.SPLICE above, but uses automatic memory management * in order to avoid freeing stuff. */ -int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 4) return RedisModule_WrongArity(ctx); +int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 4) return RedictModule_WrongArity(ctx); - RedisModule_AutoMemory(ctx); + RedictModule_AutoMemory(ctx); - RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *srckey = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], + RedictModuleKey *dstkey = RedictModule_OpenKey(ctx,argv[2], REDISMODULE_READ|REDISMODULE_WRITE); /* Src and dst key must be empty or lists. */ - if ((RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || - (RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && - RedisModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) + if ((RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST && + RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) || + (RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST && + RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY)) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || (count < 0)) { - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); } while(count-- > 0) { - RedisModuleString *ele; + RedictModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedictModule_ListPop(srckey,REDISMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedictModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); } - size_t len = RedisModule_ValueLength(srckey); - RedisModule_ReplyWithLongLong(ctx,len); + size_t len = RedictModule_ValueLength(srckey); + RedictModule_ReplyWithLongLong(ctx,len); return REDISMODULE_OK; } /* HELLO.RAND.ARRAY * Shows how to generate arrays as commands replies. * It just outputs random numbers. */ -int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); +int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 2) return RedictModule_WrongArity(ctx); long long count; - if (RedisModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK || + if (RedictModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK || count < 0) - return RedisModule_ReplyWithError(ctx,"ERR invalid count"); + return RedictModule_ReplyWithError(ctx,"ERR invalid count"); - /* To reply with an array, we call RedisModule_ReplyWithArray() followed + /* To reply with an array, we call RedictModule_ReplyWithArray() followed * by other "count" calls to other reply functions in order to generate * the elements of the array. */ - RedisModule_ReplyWithArray(ctx,count); - while(count--) RedisModule_ReplyWithLongLong(ctx,rand()); + RedictModule_ReplyWithArray(ctx,count); + while(count--) RedictModule_ReplyWithLongLong(ctx,rand()); return REDISMODULE_OK; } /* This is a simple command to test replication. Because of the "!" modified - * in the RedisModule_Call() call, the two INCRs get replicated. + * in the RedictModule_Call() call, the two INCRs get replicated. * Also note how the ECHO is replicated in an unexpected position (check * comments the function implementation). */ -int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) +int HelloRepl1_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { REDISMODULE_NOT_USED(argv); REDISMODULE_NOT_USED(argc); - RedisModule_AutoMemory(ctx); + RedictModule_AutoMemory(ctx); /* This will be replicated *after* the two INCR statements, since * the Call() replication has precedence, so the actual replication @@ -223,20 +223,20 @@ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * ECHO c foo * EXEC */ - RedisModule_Replicate(ctx,"ECHO","c","foo"); + RedictModule_Replicate(ctx,"ECHO","c","foo"); /* Using the "!" modifier we replicate the command if it * modified the dataset in some way. */ - RedisModule_Call(ctx,"INCR","c!","foo"); - RedisModule_Call(ctx,"INCR","c!","bar"); + RedictModule_Call(ctx,"INCR","c!","foo"); + RedictModule_Call(ctx,"INCR","c!","bar"); - RedisModule_ReplyWithLongLong(ctx,0); + RedictModule_ReplyWithLongLong(ctx,0); return REDISMODULE_OK; } /* Another command to show replication. In this case, we call - * RedisModule_ReplicateVerbatim() to mean we want just the command to be + * RedictModule_ReplicateVerbatim() to mean we want just the command to be * propagated to slaves / AOF exactly as it was called by the user. * * This command also shows how to work with string objects. @@ -245,31 +245,31 @@ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * as reply. * * Usage: HELLO.REPL2 */ -int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); +int HelloRepl2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 2) return RedictModule_WrongArity(ctx); - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST) - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST) + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); - size_t listlen = RedisModule_ValueLength(key); + size_t listlen = RedictModule_ValueLength(key); long long sum = 0; /* Rotate and increment. */ while(listlen--) { - RedisModuleString *ele = RedisModule_ListPop(key,REDISMODULE_LIST_TAIL); + RedictModuleString *ele = RedictModule_ListPop(key,REDISMODULE_LIST_TAIL); long long val; - if (RedisModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0; + if (RedictModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0; val++; sum += val; - RedisModuleString *newele = RedisModule_CreateStringFromLongLong(ctx,val); - RedisModule_ListPush(key,REDISMODULE_LIST_HEAD,newele); + RedictModuleString *newele = RedictModule_CreateStringFromLongLong(ctx,val); + RedictModule_ListPush(key,REDISMODULE_LIST_HEAD,newele); } - RedisModule_ReplyWithLongLong(ctx,sum); - RedisModule_ReplicateVerbatim(ctx); + RedictModule_ReplyWithLongLong(ctx,sum); + RedictModule_ReplicateVerbatim(ctx); return REDISMODULE_OK; } @@ -281,23 +281,23 @@ int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * of variety). * * HELLO.TOGGLE.CASE key */ -int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (argc != 2) return RedisModule_WrongArity(ctx); +int HelloToggleCase_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (argc != 2) return RedictModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int keytype = RedisModule_KeyType(key); + int keytype = RedictModule_KeyType(key); if (keytype != REDISMODULE_KEYTYPE_STRING && keytype != REDISMODULE_KEYTYPE_EMPTY) { - RedisModule_CloseKey(key); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + RedictModule_CloseKey(key); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } if (keytype == REDISMODULE_KEYTYPE_STRING) { size_t len, j; - char *s = RedisModule_StringDMA(key,&len,REDISMODULE_WRITE); + char *s = RedictModule_StringDMA(key,&len,REDISMODULE_WRITE); for (j = 0; j < len; j++) { if (isupper(s[j])) { s[j] = tolower(s[j]); @@ -307,9 +307,9 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } } - RedisModule_CloseKey(key); - RedisModule_ReplyWithSimpleString(ctx,"OK"); - RedisModule_ReplicateVerbatim(ctx); + RedictModule_CloseKey(key); + RedictModule_ReplyWithSimpleString(ctx,"OK"); + RedictModule_ReplicateVerbatim(ctx); return REDISMODULE_OK; } @@ -317,23 +317,23 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, * * If the key has already an associated TTL, extends it by "milliseconds" * milliseconds. Otherwise no operation is performed. */ -int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 3) return RedisModule_WrongArity(ctx); +int HelloMoreExpire_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ + if (argc != 3) return RedictModule_WrongArity(ctx); mstime_t addms, expire; - if (RedisModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK) - return RedisModule_ReplyWithError(ctx,"ERR invalid expire time"); + if (RedictModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK) + return RedictModule_ReplyWithError(ctx,"ERR invalid expire time"); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - expire = RedisModule_GetExpire(key); + expire = RedictModule_GetExpire(key); if (expire != REDISMODULE_NO_EXPIRE) { expire += addms; - RedisModule_SetExpire(key,expire); + RedictModule_SetExpire(key,expire); } - return RedisModule_ReplyWithSimpleString(ctx,"OK"); + return RedictModule_ReplyWithSimpleString(ctx,"OK"); } /* HELLO.ZSUMRANGE key startscore endscore @@ -342,51 +342,51 @@ int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, * The computation is performed two times, one time from start to end and * another time backward. The two scores, returned as a two element array, * should match.*/ -int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { +int HelloZsumRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { double score_start, score_end; - if (argc != 4) return RedisModule_WrongArity(ctx); + if (argc != 4) return RedictModule_WrongArity(ctx); - if (RedisModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK || - RedisModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK) + if (RedictModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK || + RedictModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx,"ERR invalid range"); + return RedictModule_ReplyWithError(ctx,"ERR invalid range"); } - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } double scoresum_a = 0; double scoresum_b = 0; - RedisModule_ZsetFirstInScoreRange(key,score_start,score_end,0,0); - while(!RedisModule_ZsetRangeEndReached(key)) { + RedictModule_ZsetFirstInScoreRange(key,score_start,score_end,0,0); + while(!RedictModule_ZsetRangeEndReached(key)) { double score; - RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score); - RedisModule_FreeString(ctx,ele); + RedictModuleString *ele = RedictModule_ZsetRangeCurrentElement(key,&score); + RedictModule_FreeString(ctx,ele); scoresum_a += score; - RedisModule_ZsetRangeNext(key); + RedictModule_ZsetRangeNext(key); } - RedisModule_ZsetRangeStop(key); + RedictModule_ZsetRangeStop(key); - RedisModule_ZsetLastInScoreRange(key,score_start,score_end,0,0); - while(!RedisModule_ZsetRangeEndReached(key)) { + RedictModule_ZsetLastInScoreRange(key,score_start,score_end,0,0); + while(!RedictModule_ZsetRangeEndReached(key)) { double score; - RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score); - RedisModule_FreeString(ctx,ele); + RedictModuleString *ele = RedictModule_ZsetRangeCurrentElement(key,&score); + RedictModule_FreeString(ctx,ele); scoresum_b += score; - RedisModule_ZsetRangePrev(key); + RedictModule_ZsetRangePrev(key); } - RedisModule_ZsetRangeStop(key); + RedictModule_ZsetRangeStop(key); - RedisModule_CloseKey(key); + RedictModule_CloseKey(key); - RedisModule_ReplyWithArray(ctx,2); - RedisModule_ReplyWithDouble(ctx,scoresum_a); - RedisModule_ReplyWithDouble(ctx,scoresum_b); + RedictModule_ReplyWithArray(ctx,2); + RedictModule_ReplyWithDouble(ctx,scoresum_a); + RedictModule_ReplyWithDouble(ctx,scoresum_b); return REDISMODULE_OK; } @@ -397,34 +397,34 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i * The command will return all the sorted set items that are lexicographically * between the specified range (using the same format as ZRANGEBYLEX) * and having an age between min_age and max_age. */ -int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloLexRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 6) return RedisModule_WrongArity(ctx); + if (argc != 6) return RedictModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } - if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) { - return RedisModule_ReplyWithError(ctx,"invalid range"); + if (RedictModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) { + return RedictModule_ReplyWithError(ctx,"invalid range"); } int arraylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); - while(!RedisModule_ZsetRangeEndReached(key)) { + RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + while(!RedictModule_ZsetRangeEndReached(key)) { double score; - RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score); - RedisModule_ReplyWithString(ctx,ele); - RedisModule_FreeString(ctx,ele); - RedisModule_ZsetRangeNext(key); + RedictModuleString *ele = RedictModule_ZsetRangeCurrentElement(key,&score); + RedictModule_ReplyWithString(ctx,ele); + RedictModule_FreeString(ctx,ele); + RedictModule_ZsetRangeNext(key); arraylen++; } - RedisModule_ZsetRangeStop(key); - RedisModule_ReplySetArrayLength(ctx,arraylen); - RedisModule_CloseKey(key); + RedictModule_ZsetRangeStop(key); + RedictModule_ReplySetArrayLength(ctx,arraylen); + RedictModule_CloseKey(key); return REDISMODULE_OK; } @@ -435,26 +435,26 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in * * The command returns 1 if the copy is performed (srcfield exists) otherwise * 0 is returned. */ -int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloHCopy_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ - if (argc != 4) return RedisModule_WrongArity(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], + if (argc != 4) return RedictModule_WrongArity(ctx); + RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1], REDISMODULE_READ|REDISMODULE_WRITE); - int type = RedisModule_KeyType(key); + int type = RedictModule_KeyType(key); if (type != REDISMODULE_KEYTYPE_HASH && type != REDISMODULE_KEYTYPE_EMPTY) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); } /* Get the old field value. */ - RedisModuleString *oldval; - RedisModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL); + RedictModuleString *oldval; + RedictModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL); if (oldval) { - RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL); + RedictModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL); } - RedisModule_ReplyWithLongLong(ctx,oldval != NULL); + RedictModule_ReplyWithLongLong(ctx,oldval != NULL); return REDISMODULE_OK; } @@ -471,119 +471,119 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a * the callback implementing the command returns. So in that case the module * does not need to retain a reference to these allocations, it is just * required to free the memory before returning. When this is the case the - * module can call RedisModule_PoolAlloc() instead, that works like malloc() + * module can call RedictModule_PoolAlloc() instead, that works like malloc() * but will automatically free the memory when the module callback returns. * * Note that PoolAlloc() does not necessarily require AutoMemory to be * active. */ -int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ +int HelloLeftPad_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + RedictModule_AutoMemory(ctx); /* Use automatic memory management. */ long long padlen; - if (argc != 4) return RedisModule_WrongArity(ctx); + if (argc != 4) return RedictModule_WrongArity(ctx); - if ((RedisModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) || + if ((RedictModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) || (padlen< 0)) { - return RedisModule_ReplyWithError(ctx,"ERR invalid padding length"); + return RedictModule_ReplyWithError(ctx,"ERR invalid padding length"); } size_t strlen, chlen; - const char *str = RedisModule_StringPtrLen(argv[1], &strlen); - const char *ch = RedisModule_StringPtrLen(argv[3], &chlen); + const char *str = RedictModule_StringPtrLen(argv[1], &strlen); + const char *ch = RedictModule_StringPtrLen(argv[3], &chlen); /* If the string is already larger than the target len, just return * the string itself. */ if (strlen >= (size_t)padlen) - return RedisModule_ReplyWithString(ctx,argv[1]); + return RedictModule_ReplyWithString(ctx,argv[1]); /* Padding must be a single character in this simple implementation. */ if (chlen != 1) - return RedisModule_ReplyWithError(ctx, + return RedictModule_ReplyWithError(ctx, "ERR padding must be a single char"); /* Here we use our pool allocator, for our throw-away allocation. */ padlen -= strlen; - char *buf = RedisModule_PoolAlloc(ctx,padlen+strlen); + char *buf = RedictModule_PoolAlloc(ctx,padlen+strlen); for (long long j = 0; j < padlen; j++) buf[j] = *ch; memcpy(buf+padlen,str,strlen); - RedisModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen); + RedictModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen); return REDISMODULE_OK; } /* This function must be present on each Redis module. It is used in order to * register the commands into the Redis server. */ -int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - if (RedisModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1) +int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) { + if (RedictModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; /* Log the list of parameters passing loading the module. */ for (int j = 0; j < argc; j++) { - const char *s = RedisModule_StringPtrLen(argv[j],NULL); + const char *s = RedictModule_StringPtrLen(argv[j],NULL); printf("Module loaded with ARGV[%d] = %s\n", j, s); } - if (RedisModule_CreateCommand(ctx,"hello.simple", + if (RedictModule_CreateCommand(ctx,"hello.simple", HelloSimple_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.push.native", + if (RedictModule_CreateCommand(ctx,"hello.push.native", HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.push.call", + if (RedictModule_CreateCommand(ctx,"hello.push.call", HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.push.call2", + if (RedictModule_CreateCommand(ctx,"hello.push.call2", HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.list.sum.len", + if (RedictModule_CreateCommand(ctx,"hello.list.sum.len", HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.list.splice", + if (RedictModule_CreateCommand(ctx,"hello.list.splice", HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.list.splice.auto", + if (RedictModule_CreateCommand(ctx,"hello.list.splice.auto", HelloListSpliceAuto_RedisCommand, "write deny-oom",1,2,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.rand.array", + if (RedictModule_CreateCommand(ctx,"hello.rand.array", HelloRandArray_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.repl1", + if (RedictModule_CreateCommand(ctx,"hello.repl1", HelloRepl1_RedisCommand,"write",0,0,0) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.repl2", + if (RedictModule_CreateCommand(ctx,"hello.repl2", HelloRepl2_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.toggle.case", + if (RedictModule_CreateCommand(ctx,"hello.toggle.case", HelloToggleCase_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.more.expire", + if (RedictModule_CreateCommand(ctx,"hello.more.expire", HelloMoreExpire_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.zsumrange", + if (RedictModule_CreateCommand(ctx,"hello.zsumrange", HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.lexrange", + if (RedictModule_CreateCommand(ctx,"hello.lexrange", HelloLexRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.hcopy", + if (RedictModule_CreateCommand(ctx,"hello.hcopy", HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx,"hello.leftpad", + if (RedictModule_CreateCommand(ctx,"hello.leftpad", HelloLeftPad_RedisCommand,"",1,1,1) == REDISMODULE_ERR) return REDISMODULE_ERR; diff --git a/src/networking.c b/src/networking.c index 4694e7e11..fb081f2ed 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1560,7 +1560,7 @@ void freeClient(client *c) { /* Notify module system that this client auth status changed. */ moduleNotifyUserChanged(c); - /* Free the RedisModuleBlockedClient held onto for reprocessing if not already freed. */ + /* Free the RedictModuleBlockedClient held onto for reprocessing if not already freed. */ zfree(c->module_blocked_client); /* If this client was scheduled for async freeing we need to remove it diff --git a/src/rdb.c b/src/rdb.c index a8a8c38cf..da65cdec0 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1057,7 +1057,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o, robj *key, int dbid) { } } else if (o->type == OBJ_MODULE) { /* Save a module-specific value. */ - RedisModuleIO io; + RedictModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; @@ -1193,7 +1193,7 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { ssize_t rdbSaveSingleModuleAux(rio *rdb, int when, moduleType *mt) { /* Save a module-specific aux value. */ - RedisModuleIO io; + RedictModuleIO io; int retval = 0; moduleInitIOContext(io,mt,rdb,NULL,-1); @@ -2790,7 +2790,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb, sds key, int dbid, int *error) { rdbReportCorruptRDB("The RDB file contains module data I can't load: no matching module type '%s'", name); return NULL; } - RedisModuleIO io; + RedictModuleIO io; robj keyobj; initStaticStringObject(keyobj,key); moduleInitIOContext(io,mt,rdb,&keyobj,dbid); @@ -3197,7 +3197,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin exit(1); } - RedisModuleIO io; + RedictModuleIO io; moduleInitIOContext(io,mt,rdb,NULL,-1); /* Call the rdb_load method of the module providing the 10 bit * encoding version in the lower 10 bits of the module ID. */ diff --git a/src/redictmodule.h b/src/redictmodule.h index 5f2dbe03e..f1586ea82 100644 --- a/src/redictmodule.h +++ b/src/redictmodule.h @@ -12,8 +12,8 @@ #include -typedef struct RedisModuleString RedisModuleString; -typedef struct RedisModuleKey RedisModuleKey; +typedef struct RedictModuleString RedictModuleString; +typedef struct RedictModuleKey RedictModuleKey; /* -------------- Defines NOT common between core and modules ------------- */ @@ -21,7 +21,7 @@ typedef struct RedisModuleKey RedisModuleKey; /* Things only defined for the modules core (server), not exported to modules * that include this file. */ -#define RedisModuleString robj +#define RedictModuleString robj #endif /* defined REDISMODULE_CORE */ @@ -46,7 +46,7 @@ typedef long long ustime_t; /* API versions. */ #define REDISMODULE_APIVER_1 1 -/* Version of the RedisModuleTypeMethods structure. Once the RedisModuleTypeMethods +/* Version of the RedictModuleTypeMethods structure. Once the RedictModuleTypeMethods * structure is changed, this version number needs to be changed synchronistically. */ #define REDISMODULE_TYPE_METHOD_VERSION 5 @@ -54,7 +54,7 @@ typedef long long ustime_t; #define REDISMODULE_READ (1<<0) #define REDISMODULE_WRITE (1<<1) -/* RedisModule_OpenKey extra flags for the 'mode' argument. +/* RedictModule_OpenKey extra flags for the 'mode' argument. * Avoid touching the LRU/LFU of the key when opened. */ #define REDISMODULE_OPEN_KEY_NOTOUCH (1<<16) /* Don't trigger keyspace event on key misses. */ @@ -135,10 +135,10 @@ typedef long long ustime_t; #define REDISMODULE_CONFIG_BITFLAGS (1ULL<<8) /* Indicates if this value can be set as a multiple enum values */ /* StreamID type. */ -typedef struct RedisModuleStreamID { +typedef struct RedictModuleStreamID { uint64_t ms; uint64_t seq; -} RedisModuleStreamID; +} RedictModuleStreamID; /* StreamAdd() flags. */ #define REDISMODULE_STREAM_ADD_AUTOID (1<<0) @@ -211,7 +211,7 @@ typedef struct RedisModuleStreamID { /* Next context flag, must be updated when adding new flags above! This flag should not be used directly by the module. - * Use RedisModule_GetContextFlagsAll instead. */ + * Use RedictModule_GetContextFlagsAll instead. */ #define _REDISMODULE_CTX_FLAGS_NEXT (1<<25) /* Keyspace changes notification classes. Every class is associated with a @@ -235,14 +235,14 @@ This flag should not be used directly by the module. /* Next notification flag, must be updated when adding new flags above! This flag should not be used directly by the module. - * Use RedisModule_GetKeyspaceNotificationFlagsAll instead. */ + * Use RedictModule_GetKeyspaceNotificationFlagsAll instead. */ #define _REDISMODULE_NOTIFY_NEXT (1<<15) #define REDISMODULE_NOTIFY_ALL (REDISMODULE_NOTIFY_GENERIC | REDISMODULE_NOTIFY_STRING | REDISMODULE_NOTIFY_LIST | REDISMODULE_NOTIFY_SET | REDISMODULE_NOTIFY_HASH | REDISMODULE_NOTIFY_ZSET | REDISMODULE_NOTIFY_EXPIRED | REDISMODULE_NOTIFY_EVICTED | REDISMODULE_NOTIFY_STREAM | REDISMODULE_NOTIFY_MODULE) /* A */ /* A special pointer that we can use between the core and the module to signal * field deletion, and that is impossible to be a valid pointer. */ -#define REDISMODULE_HASH_DELETE ((RedisModuleString*)(long)1) +#define REDISMODULE_HASH_DELETE ((RedictModuleString*)(long)1) /* Error messages. */ #define REDISMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value" @@ -287,22 +287,22 @@ This flag should not be used directly by the module. * registered and used in order to invalidate a timer. It's just a 64 bit * number, because this is how each timer is represented inside the radix tree * of timers that are going to expire, sorted by expire time. */ -typedef uint64_t RedisModuleTimerID; +typedef uint64_t RedictModuleTimerID; /* CommandFilter Flags */ -/* Do filter RedisModule_Call() commands initiated by module itself. */ +/* Do filter RedictModule_Call() commands initiated by module itself. */ #define REDISMODULE_CMDFILTER_NOSELF (1<<0) -/* Declare that the module can handle errors with RedisModule_SetModuleOptions. */ +/* Declare that the module can handle errors with RedictModule_SetModuleOptions. */ #define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0) -/* When set, Redis will not call RedisModule_SignalModifiedKey(), implicitly in - * RedisModule_CloseKey, and the module needs to do that when manually when keys +/* When set, Redis will not call RedictModule_SignalModifiedKey(), implicitly in + * RedictModule_CloseKey, and the module needs to do that when manually when keys * are modified from the user's perspective, to invalidate WATCH. */ #define REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1) -/* Declare that the module can handle diskless async replication with RedisModule_SetModuleOptions. */ +/* Declare that the module can handle diskless async replication with RedictModule_SetModuleOptions. */ #define REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD (1<<2) /* Declare that the module want to get nested key space notifications. @@ -311,10 +311,10 @@ typedef uint64_t RedisModuleTimerID; /* Next option flag, must be updated when adding new module flags above! * This flag should not be used directly by the module. - * Use RedisModule_GetModuleOptionsAll instead. */ + * Use RedictModule_GetModuleOptionsAll instead. */ #define _REDISMODULE_OPTIONS_FLAGS_NEXT (1<<4) -/* Definitions for RedisModule_SetCommandInfo. */ +/* Definitions for RedictModule_SetCommandInfo. */ typedef enum { REDISMODULE_ARG_TYPE_STRING, @@ -326,7 +326,7 @@ typedef enum { REDISMODULE_ARG_TYPE_PURE_TOKEN, REDISMODULE_ARG_TYPE_ONEOF, /* Must have sub-arguments */ REDISMODULE_ARG_TYPE_BLOCK /* Must have sub-arguments */ -} RedisModuleCommandArgType; +} RedictModuleCommandArgType; #define REDISMODULE_CMD_ARG_NONE (0) #define REDISMODULE_CMD_ARG_OPTIONAL (1<<0) /* The argument is optional (like GET in SET command) */ @@ -341,7 +341,7 @@ typedef enum { REDISMODULE_KSPEC_BS_UNKNOWN, REDISMODULE_KSPEC_BS_INDEX, REDISMODULE_KSPEC_BS_KEYWORD -} RedisModuleKeySpecBeginSearchType; +} RedictModuleKeySpecBeginSearchType; typedef enum { REDISMODULE_KSPEC_FK_OMITTED = 0, /* Used when the field is absent in a @@ -350,10 +350,10 @@ typedef enum { REDISMODULE_KSPEC_FK_UNKNOWN, REDISMODULE_KSPEC_FK_RANGE, REDISMODULE_KSPEC_FK_KEYNUM -} RedisModuleKeySpecFindKeysType; +} RedictModuleKeySpecFindKeysType; /* Key-spec flags. For details, see the documentation of - * RedisModule_SetCommandInfo and the key-spec flags in server.h. */ + * RedictModule_SetCommandInfo and the key-spec flags in server.h. */ #define REDISMODULE_CMD_KEY_RO (1ULL<<0) #define REDISMODULE_CMD_KEY_RW (1ULL<<1) #define REDISMODULE_CMD_KEY_OW (1ULL<<2) @@ -367,15 +367,15 @@ typedef enum { #define REDISMODULE_CMD_KEY_VARIABLE_FLAGS (1ULL<<10) /* Channel flags, for details see the documentation of - * RedisModule_ChannelAtPosWithFlags. */ + * RedictModule_ChannelAtPosWithFlags. */ #define REDISMODULE_CMD_CHANNEL_PATTERN (1ULL<<0) #define REDISMODULE_CMD_CHANNEL_PUBLISH (1ULL<<1) #define REDISMODULE_CMD_CHANNEL_SUBSCRIBE (1ULL<<2) #define REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE (1ULL<<3) -typedef struct RedisModuleCommandArg { +typedef struct RedictModuleCommandArg { const char *name; - RedisModuleCommandArgType type; + RedictModuleCommandArgType type; int key_spec_index; /* If type is KEY, this is a zero-based index of * the key_spec in the command. For other types, * you may specify -1. */ @@ -384,19 +384,19 @@ typedef struct RedisModuleCommandArg { const char *since; int flags; /* The REDISMODULE_CMD_ARG_* macros. */ const char *deprecated_since; - struct RedisModuleCommandArg *subargs; + struct RedictModuleCommandArg *subargs; const char *display_text; -} RedisModuleCommandArg; +} RedictModuleCommandArg; typedef struct { const char *since; const char *changes; -} RedisModuleCommandHistoryEntry; +} RedictModuleCommandHistoryEntry; typedef struct { const char *notes; uint64_t flags; /* REDISMODULE_CMD_KEY_* macros. */ - RedisModuleKeySpecBeginSearchType begin_search_type; + RedictModuleKeySpecBeginSearchType begin_search_type; union { struct { /* The index from which we start the search for keys */ @@ -411,7 +411,7 @@ typedef struct { int startfrom; } keyword; } bs; - RedisModuleKeySpecFindKeysType find_keys_type; + RedictModuleKeySpecFindKeysType find_keys_type; union { struct { /* Index of the last key relative to the result of the begin search @@ -440,50 +440,50 @@ typedef struct { int keystep; } keynum; } fk; -} RedisModuleCommandKeySpec; +} RedictModuleCommandKeySpec; typedef struct { int version; size_t sizeof_historyentry; size_t sizeof_keyspec; size_t sizeof_arg; -} RedisModuleCommandInfoVersion; +} RedictModuleCommandInfoVersion; -static const RedisModuleCommandInfoVersion RedisModule_CurrentCommandInfoVersion = { +static const RedictModuleCommandInfoVersion RedictModule_CurrentCommandInfoVersion = { .version = 1, - .sizeof_historyentry = sizeof(RedisModuleCommandHistoryEntry), - .sizeof_keyspec = sizeof(RedisModuleCommandKeySpec), - .sizeof_arg = sizeof(RedisModuleCommandArg) + .sizeof_historyentry = sizeof(RedictModuleCommandHistoryEntry), + .sizeof_keyspec = sizeof(RedictModuleCommandKeySpec), + .sizeof_arg = sizeof(RedictModuleCommandArg) }; -#define REDISMODULE_COMMAND_INFO_VERSION (&RedisModule_CurrentCommandInfoVersion) +#define REDISMODULE_COMMAND_INFO_VERSION (&RedictModule_CurrentCommandInfoVersion) typedef struct { /* Always set version to REDISMODULE_COMMAND_INFO_VERSION */ - const RedisModuleCommandInfoVersion *version; + const RedictModuleCommandInfoVersion *version; /* Version 1 fields (added in Redis 7.0.0) */ const char *summary; /* Summary of the command */ const char *complexity; /* Complexity description */ const char *since; /* Debut module version of the command */ - RedisModuleCommandHistoryEntry *history; /* History */ + RedictModuleCommandHistoryEntry *history; /* History */ /* A string of space-separated tips meant for clients/proxies regarding this * command */ const char *tips; /* Number of arguments, it is possible to use -N to say >= N */ int arity; - RedisModuleCommandKeySpec *key_specs; - RedisModuleCommandArg *args; -} RedisModuleCommandInfo; + RedictModuleCommandKeySpec *key_specs; + RedictModuleCommandArg *args; +} RedictModuleCommandInfo; /* Eventloop definitions. */ #define REDISMODULE_EVENTLOOP_READABLE 1 #define REDISMODULE_EVENTLOOP_WRITABLE 2 -typedef void (*RedisModuleEventLoopFunc)(int fd, void *user_data, int mask); -typedef void (*RedisModuleEventLoopOneShotFunc)(void *user_data); +typedef void (*RedictModuleEventLoopFunc)(int fd, void *user_data, int mask); +typedef void (*RedictModuleEventLoopOneShotFunc)(void *user_data); /* Server events definitions. * Those flags should not be used directly by the module, instead - * the module should use RedisModuleEvent_* variables. + * the module should use RedictModuleEvent_* variables. * Note: This must be synced with moduleEventVersions */ #define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 #define REDISMODULE_EVENT_PERSISTENCE 1 @@ -505,34 +505,34 @@ typedef void (*RedisModuleEventLoopOneShotFunc)(void *user_data); #define REDISMODULE_EVENT_KEY 17 #define _REDISMODULE_EVENT_NEXT 18 /* Next event flag, should be updated if a new event added. */ -typedef struct RedisModuleEvent { +typedef struct RedictModuleEvent { uint64_t id; /* REDISMODULE_EVENT_... defines. */ uint64_t dataver; /* Version of the structure we pass as 'data'. */ -} RedisModuleEvent; +} RedictModuleEvent; -struct RedisModuleCtx; -struct RedisModuleDefragCtx; -typedef void (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data); +struct RedictModuleCtx; +struct RedictModuleDefragCtx; +typedef void (*RedictModuleEventCallback)(struct RedictModuleCtx *ctx, RedictModuleEvent eid, uint64_t subevent, void *data); /* IMPORTANT: When adding a new version of one of below structures that contain - * event data (RedisModuleFlushInfoV1 for example) we have to avoid renaming the - * old RedisModuleEvent structure. - * For example, if we want to add RedisModuleFlushInfoV2, the RedisModuleEvent + * event data (RedictModuleFlushInfoV1 for example) we have to avoid renaming the + * old RedictModuleEvent structure. + * For example, if we want to add RedictModuleFlushInfoV2, the RedictModuleEvent * structures should be: - * RedisModuleEvent_FlushDB = { + * RedictModuleEvent_FlushDB = { * REDISMODULE_EVENT_FLUSHDB, * 1 * }, - * RedisModuleEvent_FlushDBV2 = { + * RedictModuleEvent_FlushDBV2 = { * REDISMODULE_EVENT_FLUSHDB, * 2 * } * and NOT: - * RedisModuleEvent_FlushDBV1 = { + * RedictModuleEvent_FlushDBV1 = { * REDISMODULE_EVENT_FLUSHDB, * 1 * }, - * RedisModuleEvent_FlushDB = { + * RedictModuleEvent_FlushDB = { * REDISMODULE_EVENT_FLUSHDB, * 2 * } @@ -540,78 +540,78 @@ typedef void (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModule * compiled with a new redictmodule.h to be able to work with a old server, * unless the author explicitly decided to use the newer event type. */ -static const RedisModuleEvent - RedisModuleEvent_ReplicationRoleChanged = { +static const RedictModuleEvent + RedictModuleEvent_ReplicationRoleChanged = { REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, 1 }, - RedisModuleEvent_Persistence = { + RedictModuleEvent_Persistence = { REDISMODULE_EVENT_PERSISTENCE, 1 }, - RedisModuleEvent_FlushDB = { + RedictModuleEvent_FlushDB = { REDISMODULE_EVENT_FLUSHDB, 1 }, - RedisModuleEvent_Loading = { + RedictModuleEvent_Loading = { REDISMODULE_EVENT_LOADING, 1 }, - RedisModuleEvent_ClientChange = { + RedictModuleEvent_ClientChange = { REDISMODULE_EVENT_CLIENT_CHANGE, 1 }, - RedisModuleEvent_Shutdown = { + RedictModuleEvent_Shutdown = { REDISMODULE_EVENT_SHUTDOWN, 1 }, - RedisModuleEvent_ReplicaChange = { + RedictModuleEvent_ReplicaChange = { REDISMODULE_EVENT_REPLICA_CHANGE, 1 }, - RedisModuleEvent_CronLoop = { + RedictModuleEvent_CronLoop = { REDISMODULE_EVENT_CRON_LOOP, 1 }, - RedisModuleEvent_MasterLinkChange = { + RedictModuleEvent_MasterLinkChange = { REDISMODULE_EVENT_MASTER_LINK_CHANGE, 1 }, - RedisModuleEvent_ModuleChange = { + RedictModuleEvent_ModuleChange = { REDISMODULE_EVENT_MODULE_CHANGE, 1 }, - RedisModuleEvent_LoadingProgress = { + RedictModuleEvent_LoadingProgress = { REDISMODULE_EVENT_LOADING_PROGRESS, 1 }, - RedisModuleEvent_SwapDB = { + RedictModuleEvent_SwapDB = { REDISMODULE_EVENT_SWAPDB, 1 }, /* Deprecated since Redis 7.0, not used anymore. */ __attribute__ ((deprecated)) - RedisModuleEvent_ReplBackup = { + RedictModuleEvent_ReplBackup = { REDISMODULE_EVENT_REPL_BACKUP, 1 }, - RedisModuleEvent_ReplAsyncLoad = { + RedictModuleEvent_ReplAsyncLoad = { REDISMODULE_EVENT_REPL_ASYNC_LOAD, 1 }, - RedisModuleEvent_ForkChild = { + RedictModuleEvent_ForkChild = { REDISMODULE_EVENT_FORK_CHILD, 1 }, - RedisModuleEvent_EventLoop = { + RedictModuleEvent_EventLoop = { REDISMODULE_EVENT_EVENTLOOP, 1 }, - RedisModuleEvent_Config = { + RedictModuleEvent_Config = { REDISMODULE_EVENT_CONFIG, 1 }, - RedisModuleEvent_Key = { + RedictModuleEvent_Key = { REDISMODULE_EVENT_KEY, 1 }; @@ -692,7 +692,7 @@ static const RedisModuleEvent #define _REDISMODULE_SUBEVENT_CRON_LOOP_NEXT 0 #define _REDISMODULE_SUBEVENT_SWAPDB_NEXT 0 -/* RedisModuleClientInfo flags. */ +/* RedictModuleClientInfo flags. */ #define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0) #define REDISMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1) #define REDISMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2) @@ -702,7 +702,7 @@ static const RedisModuleEvent /* Here we take all the structures that the module pass to the core * and the other way around. Notably the list here contains the structures - * used by the hooks API RedisModule_RegisterToServerEvent(). + * used by the hooks API RedictModule_RegisterToServerEvent(). * * The structures always start with a 'version' field. This is useful * when we want to pass a reference to the structure to the core APIs, @@ -716,21 +716,21 @@ static const RedisModuleEvent * public name for the module to use. */ #define REDISMODULE_CLIENTINFO_VERSION 1 -typedef struct RedisModuleClientInfo { +typedef struct RedictModuleClientInfo { uint64_t version; /* Version of this structure for ABI compat. */ uint64_t flags; /* REDISMODULE_CLIENTINFO_FLAG_* */ uint64_t id; /* Client ID. */ char addr[46]; /* IPv4 or IPv6 address. */ uint16_t port; /* TCP port. */ uint16_t db; /* Selected DB. */ -} RedisModuleClientInfoV1; +} RedictModuleClientInfoV1; -#define RedisModuleClientInfo RedisModuleClientInfoV1 +#define RedictModuleClientInfo RedictModuleClientInfoV1 #define REDISMODULE_CLIENTINFO_INITIALIZER_V1 { .version = 1 } #define REDISMODULE_REPLICATIONINFO_VERSION 1 -typedef struct RedisModuleReplicationInfo { +typedef struct RedictModuleReplicationInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ @@ -741,104 +741,104 @@ typedef struct RedisModuleReplicationInfo { char *replid2; /* Secondary replication ID */ uint64_t repl1_offset; /* Main replication offset */ uint64_t repl2_offset; /* Offset of replid2 validity */ -} RedisModuleReplicationInfoV1; +} RedictModuleReplicationInfoV1; -#define RedisModuleReplicationInfo RedisModuleReplicationInfoV1 +#define RedictModuleReplicationInfo RedictModuleReplicationInfoV1 #define REDISMODULE_FLUSHINFO_VERSION 1 -typedef struct RedisModuleFlushInfo { +typedef struct RedictModuleFlushInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ int32_t sync; /* Synchronous or threaded flush?. */ int32_t dbnum; /* Flushed database number, -1 for ALL. */ -} RedisModuleFlushInfoV1; +} RedictModuleFlushInfoV1; -#define RedisModuleFlushInfo RedisModuleFlushInfoV1 +#define RedictModuleFlushInfo RedictModuleFlushInfoV1 #define REDISMODULE_MODULE_CHANGE_VERSION 1 -typedef struct RedisModuleModuleChange { +typedef struct RedictModuleModuleChange { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ const char* module_name;/* Name of module loaded or unloaded. */ int32_t module_version; /* Module version. */ -} RedisModuleModuleChangeV1; +} RedictModuleModuleChangeV1; -#define RedisModuleModuleChange RedisModuleModuleChangeV1 +#define RedictModuleModuleChange RedictModuleModuleChangeV1 #define REDISMODULE_CONFIGCHANGE_VERSION 1 -typedef struct RedisModuleConfigChange { +typedef struct RedictModuleConfigChange { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ uint32_t num_changes; /* how many redis config options were changed */ const char **config_names; /* the config names that were changed */ -} RedisModuleConfigChangeV1; +} RedictModuleConfigChangeV1; -#define RedisModuleConfigChange RedisModuleConfigChangeV1 +#define RedictModuleConfigChange RedictModuleConfigChangeV1 #define REDISMODULE_CRON_LOOP_VERSION 1 -typedef struct RedisModuleCronLoopInfo { +typedef struct RedictModuleCronLoopInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ int32_t hz; /* Approximate number of events per second. */ -} RedisModuleCronLoopV1; +} RedictModuleCronLoopV1; -#define RedisModuleCronLoop RedisModuleCronLoopV1 +#define RedictModuleCronLoop RedictModuleCronLoopV1 #define REDISMODULE_LOADING_PROGRESS_VERSION 1 -typedef struct RedisModuleLoadingProgressInfo { +typedef struct RedictModuleLoadingProgressInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ int32_t hz; /* Approximate number of events per second. */ int32_t progress; /* Approximate progress between 0 and 1024, or -1 * if unknown. */ -} RedisModuleLoadingProgressV1; +} RedictModuleLoadingProgressV1; -#define RedisModuleLoadingProgress RedisModuleLoadingProgressV1 +#define RedictModuleLoadingProgress RedictModuleLoadingProgressV1 #define REDISMODULE_SWAPDBINFO_VERSION 1 -typedef struct RedisModuleSwapDbInfo { +typedef struct RedictModuleSwapDbInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ int32_t dbnum_first; /* Swap Db first dbnum */ int32_t dbnum_second; /* Swap Db second dbnum */ -} RedisModuleSwapDbInfoV1; +} RedictModuleSwapDbInfoV1; -#define RedisModuleSwapDbInfo RedisModuleSwapDbInfoV1 +#define RedictModuleSwapDbInfo RedictModuleSwapDbInfoV1 #define REDISMODULE_KEYINFO_VERSION 1 -typedef struct RedisModuleKeyInfo { +typedef struct RedictModuleKeyInfo { uint64_t version; /* Not used since this structure is never passed from the module to the core right now. Here for future compatibility. */ - RedisModuleKey *key; /* Opened key. */ -} RedisModuleKeyInfoV1; + RedictModuleKey *key; /* Opened key. */ +} RedictModuleKeyInfoV1; -#define RedisModuleKeyInfo RedisModuleKeyInfoV1 +#define RedictModuleKeyInfo RedictModuleKeyInfoV1 typedef enum { REDISMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */ REDISMODULE_ACL_LOG_CMD, /* Command authorization failure */ REDISMODULE_ACL_LOG_KEY, /* Key authorization failure */ REDISMODULE_ACL_LOG_CHANNEL /* Channel authorization failure */ -} RedisModuleACLLogEntryReason; +} RedictModuleACLLogEntryReason; /* Incomplete structures needed by both the core and modules. */ -typedef struct RedisModuleIO RedisModuleIO; -typedef struct RedisModuleDigest RedisModuleDigest; -typedef struct RedisModuleInfoCtx RedisModuleInfoCtx; -typedef struct RedisModuleDefragCtx RedisModuleDefragCtx; +typedef struct RedictModuleIO RedictModuleIO; +typedef struct RedictModuleDigest RedictModuleDigest; +typedef struct RedictModuleInfoCtx RedictModuleInfoCtx; +typedef struct RedictModuleDefragCtx RedictModuleDefragCtx; /* Function pointers needed by both the core and modules, these needs to be * exposed since you can't cast a function pointer to (void *). */ -typedef void (*RedisModuleInfoFunc)(RedisModuleInfoCtx *ctx, int for_crash_report); -typedef void (*RedisModuleDefragFunc)(RedisModuleDefragCtx *ctx); -typedef void (*RedisModuleUserChangedFunc) (uint64_t client_id, void *privdata); +typedef void (*RedictModuleInfoFunc)(RedictModuleInfoCtx *ctx, int for_crash_report); +typedef void (*RedictModuleDefragFunc)(RedictModuleDefragCtx *ctx); +typedef void (*RedictModuleUserChangedFunc) (uint64_t client_id, void *privdata); /* ------------------------- End of common defines ------------------------ */ @@ -872,84 +872,84 @@ typedef void (*RedisModuleUserChangedFunc) (uint64_t client_id, void *privdata); #endif /* Incomplete structures for compiler checks but opaque access. */ -typedef struct RedisModuleCtx RedisModuleCtx; -typedef struct RedisModuleCommand RedisModuleCommand; -typedef struct RedisModuleCallReply RedisModuleCallReply; -typedef struct RedisModuleType RedisModuleType; -typedef struct RedisModuleBlockedClient RedisModuleBlockedClient; -typedef struct RedisModuleClusterInfo RedisModuleClusterInfo; -typedef struct RedisModuleDict RedisModuleDict; -typedef struct RedisModuleDictIter RedisModuleDictIter; -typedef struct RedisModuleCommandFilterCtx RedisModuleCommandFilterCtx; -typedef struct RedisModuleCommandFilter RedisModuleCommandFilter; -typedef struct RedisModuleServerInfoData RedisModuleServerInfoData; -typedef struct RedisModuleScanCursor RedisModuleScanCursor; -typedef struct RedisModuleUser RedisModuleUser; -typedef struct RedisModuleKeyOptCtx RedisModuleKeyOptCtx; -typedef struct RedisModuleRdbStream RedisModuleRdbStream; +typedef struct RedictModuleCtx RedictModuleCtx; +typedef struct RedictModuleCommand RedictModuleCommand; +typedef struct RedictModuleCallReply RedictModuleCallReply; +typedef struct RedictModuleType RedictModuleType; +typedef struct RedictModuleBlockedClient RedictModuleBlockedClient; +typedef struct RedictModuleClusterInfo RedictModuleClusterInfo; +typedef struct RedictModuleDict RedictModuleDict; +typedef struct RedictModuleDictIter RedictModuleDictIter; +typedef struct RedictModuleCommandFilterCtx RedictModuleCommandFilterCtx; +typedef struct RedictModuleCommandFilter RedictModuleCommandFilter; +typedef struct RedictModuleServerInfoData RedictModuleServerInfoData; +typedef struct RedictModuleScanCursor RedictModuleScanCursor; +typedef struct RedictModuleUser RedictModuleUser; +typedef struct RedictModuleKeyOptCtx RedictModuleKeyOptCtx; +typedef struct RedictModuleRdbStream RedictModuleRdbStream; -typedef int (*RedisModuleCmdFunc)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc); -typedef void (*RedisModuleDisconnectFunc)(RedisModuleCtx *ctx, RedisModuleBlockedClient *bc); -typedef int (*RedisModuleNotificationFunc)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key); -typedef void (*RedisModulePostNotificationJobFunc) (RedisModuleCtx *ctx, void *pd); -typedef void *(*RedisModuleTypeLoadFunc)(RedisModuleIO *rdb, int encver); -typedef void (*RedisModuleTypeSaveFunc)(RedisModuleIO *rdb, void *value); -typedef int (*RedisModuleTypeAuxLoadFunc)(RedisModuleIO *rdb, int encver, int when); -typedef void (*RedisModuleTypeAuxSaveFunc)(RedisModuleIO *rdb, int when); -typedef void (*RedisModuleTypeRewriteFunc)(RedisModuleIO *aof, RedisModuleString *key, void *value); -typedef size_t (*RedisModuleTypeMemUsageFunc)(const void *value); -typedef size_t (*RedisModuleTypeMemUsageFunc2)(RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size); -typedef void (*RedisModuleTypeDigestFunc)(RedisModuleDigest *digest, void *value); -typedef void (*RedisModuleTypeFreeFunc)(void *value); -typedef size_t (*RedisModuleTypeFreeEffortFunc)(RedisModuleString *key, const void *value); -typedef size_t (*RedisModuleTypeFreeEffortFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef void (*RedisModuleTypeUnlinkFunc)(RedisModuleString *key, const void *value); -typedef void (*RedisModuleTypeUnlinkFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef void *(*RedisModuleTypeCopyFunc)(RedisModuleString *fromkey, RedisModuleString *tokey, const void *value); -typedef void *(*RedisModuleTypeCopyFunc2)(RedisModuleKeyOptCtx *ctx, const void *value); -typedef int (*RedisModuleTypeDefragFunc)(RedisModuleDefragCtx *ctx, RedisModuleString *key, void **value); -typedef void (*RedisModuleClusterMessageReceiver)(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); -typedef void (*RedisModuleTimerProc)(RedisModuleCtx *ctx, void *data); -typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter); -typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); -typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); -typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); -typedef RedisModuleString * (*RedisModuleConfigGetStringFunc)(const char *name, void *privdata); -typedef long long (*RedisModuleConfigGetNumericFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetBoolFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigGetEnumFunc)(const char *name, void *privdata); -typedef int (*RedisModuleConfigSetStringFunc)(const char *name, RedisModuleString *val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedisModuleString **err); -typedef int (*RedisModuleConfigApplyFunc)(RedisModuleCtx *ctx, void *privdata, RedisModuleString **err); -typedef void (*RedisModuleOnUnblocked)(RedisModuleCtx *ctx, RedisModuleCallReply *reply, void *private_data); -typedef int (*RedisModuleAuthCallback)(RedisModuleCtx *ctx, RedisModuleString *username, RedisModuleString *password, RedisModuleString **err); +typedef int (*RedictModuleCmdFunc)(RedictModuleCtx *ctx, RedictModuleString **argv, int argc); +typedef void (*RedictModuleDisconnectFunc)(RedictModuleCtx *ctx, RedictModuleBlockedClient *bc); +typedef int (*RedictModuleNotificationFunc)(RedictModuleCtx *ctx, int type, const char *event, RedictModuleString *key); +typedef void (*RedictModulePostNotificationJobFunc) (RedictModuleCtx *ctx, void *pd); +typedef void *(*RedictModuleTypeLoadFunc)(RedictModuleIO *rdb, int encver); +typedef void (*RedictModuleTypeSaveFunc)(RedictModuleIO *rdb, void *value); +typedef int (*RedictModuleTypeAuxLoadFunc)(RedictModuleIO *rdb, int encver, int when); +typedef void (*RedictModuleTypeAuxSaveFunc)(RedictModuleIO *rdb, int when); +typedef void (*RedictModuleTypeRewriteFunc)(RedictModuleIO *aof, RedictModuleString *key, void *value); +typedef size_t (*RedictModuleTypeMemUsageFunc)(const void *value); +typedef size_t (*RedictModuleTypeMemUsageFunc2)(RedictModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*RedictModuleTypeDigestFunc)(RedictModuleDigest *digest, void *value); +typedef void (*RedictModuleTypeFreeFunc)(void *value); +typedef size_t (*RedictModuleTypeFreeEffortFunc)(RedictModuleString *key, const void *value); +typedef size_t (*RedictModuleTypeFreeEffortFunc2)(RedictModuleKeyOptCtx *ctx, const void *value); +typedef void (*RedictModuleTypeUnlinkFunc)(RedictModuleString *key, const void *value); +typedef void (*RedictModuleTypeUnlinkFunc2)(RedictModuleKeyOptCtx *ctx, const void *value); +typedef void *(*RedictModuleTypeCopyFunc)(RedictModuleString *fromkey, RedictModuleString *tokey, const void *value); +typedef void *(*RedictModuleTypeCopyFunc2)(RedictModuleKeyOptCtx *ctx, const void *value); +typedef int (*RedictModuleTypeDefragFunc)(RedictModuleDefragCtx *ctx, RedictModuleString *key, void **value); +typedef void (*RedictModuleClusterMessageReceiver)(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*RedictModuleTimerProc)(RedictModuleCtx *ctx, void *data); +typedef void (*RedictModuleCommandFilterFunc) (RedictModuleCommandFilterCtx *filter); +typedef void (*RedictModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*RedictModuleScanCB)(RedictModuleCtx *ctx, RedictModuleString *keyname, RedictModuleKey *key, void *privdata); +typedef void (*RedictModuleScanKeyCB)(RedictModuleKey *key, RedictModuleString *field, RedictModuleString *value, void *privdata); +typedef RedictModuleString * (*RedictModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*RedictModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*RedictModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*RedictModuleConfigGetEnumFunc)(const char *name, void *privdata); +typedef int (*RedictModuleConfigSetStringFunc)(const char *name, RedictModuleString *val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, RedictModuleString **err); +typedef int (*RedictModuleConfigApplyFunc)(RedictModuleCtx *ctx, void *privdata, RedictModuleString **err); +typedef void (*RedictModuleOnUnblocked)(RedictModuleCtx *ctx, RedictModuleCallReply *reply, void *private_data); +typedef int (*RedictModuleAuthCallback)(RedictModuleCtx *ctx, RedictModuleString *username, RedictModuleString *password, RedictModuleString **err); -typedef struct RedisModuleTypeMethods { +typedef struct RedictModuleTypeMethods { uint64_t version; - RedisModuleTypeLoadFunc rdb_load; - RedisModuleTypeSaveFunc rdb_save; - RedisModuleTypeRewriteFunc aof_rewrite; - RedisModuleTypeMemUsageFunc mem_usage; - RedisModuleTypeDigestFunc digest; - RedisModuleTypeFreeFunc free; - RedisModuleTypeAuxLoadFunc aux_load; - RedisModuleTypeAuxSaveFunc aux_save; + RedictModuleTypeLoadFunc rdb_load; + RedictModuleTypeSaveFunc rdb_save; + RedictModuleTypeRewriteFunc aof_rewrite; + RedictModuleTypeMemUsageFunc mem_usage; + RedictModuleTypeDigestFunc digest; + RedictModuleTypeFreeFunc free; + RedictModuleTypeAuxLoadFunc aux_load; + RedictModuleTypeAuxSaveFunc aux_save; int aux_save_triggers; - RedisModuleTypeFreeEffortFunc free_effort; - RedisModuleTypeUnlinkFunc unlink; - RedisModuleTypeCopyFunc copy; - RedisModuleTypeDefragFunc defrag; - RedisModuleTypeMemUsageFunc2 mem_usage2; - RedisModuleTypeFreeEffortFunc2 free_effort2; - RedisModuleTypeUnlinkFunc2 unlink2; - RedisModuleTypeCopyFunc2 copy2; - RedisModuleTypeAuxSaveFunc aux_save2; -} RedisModuleTypeMethods; + RedictModuleTypeFreeEffortFunc free_effort; + RedictModuleTypeUnlinkFunc unlink; + RedictModuleTypeCopyFunc copy; + RedictModuleTypeDefragFunc defrag; + RedictModuleTypeMemUsageFunc2 mem_usage2; + RedictModuleTypeFreeEffortFunc2 free_effort2; + RedictModuleTypeUnlinkFunc2 unlink2; + RedictModuleTypeCopyFunc2 copy2; + RedictModuleTypeAuxSaveFunc aux_save2; +} RedictModuleTypeMethods; #define REDISMODULE_GET_API(name) \ - RedisModule_GetApi("RedisModule_" #name, ((void **)&RedisModule_ ## name)) + RedictModule_GetApi("RedictModule_" #name, ((void **)&RedictModule_ ## name)) /* Default API declaration prefix (not 'extern' for backwards compatibility) */ #ifndef REDISMODULE_API @@ -961,373 +961,373 @@ typedef struct RedisModuleTypeMethods { #define REDISMODULE_ATTR REDISMODULE_ATTR_COMMON #endif -REDISMODULE_API void * (*RedisModule_Alloc)(size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryAlloc)(size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_Realloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryRealloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Free)(void *ptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_Calloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_TryCalloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_Strdup)(const char *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetApi)(const char *, void *) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CreateCommand)(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCommand *(*RedisModule_GetCommand)(RedisModuleCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CreateSubcommand)(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetCommandInfo)(RedisModuleCommand *command, const RedisModuleCommandInfo *info) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetCommandACLCategories)(RedisModuleCommand *command, const char *ctgrsflags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AddACLCategory)(RedisModuleCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetModuleAttribs)(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsModuleNameBusy)(const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_WrongArity)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetSelectedDb)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SelectDb)(RedisModuleCtx *ctx, int newid) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KeyExists)(RedisModuleCtx *ctx, RedisModuleString *keyname) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleKey * (*RedisModule_OpenKey)(RedisModuleCtx *ctx, RedisModuleString *keyname, int mode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetOpenKeyModesAll)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_CloseKey)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KeyType)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_ValueLength)(RedisModuleKey *kp) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListPush)(RedisModuleKey *kp, int where, RedisModuleString *ele) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ListPop)(RedisModuleKey *key, int where) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ListGet)(RedisModuleKey *key, long index) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListSet)(RedisModuleKey *key, long index, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListInsert)(RedisModuleKey *key, long index, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ListDelete)(RedisModuleKey *key, long index) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_Call)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_CallReplyProto)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyType)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_CallReplyInteger)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_CallReplyDouble)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyBool)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API const char* (*RedisModule_CallReplyBigNumber)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API const char* (*RedisModule_CallReplyVerbatim)(RedisModuleCallReply *reply, size_t *len, const char **format) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplySetElement)(RedisModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyMapElement)(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyAttributeElement)(RedisModuleCallReply *reply, size_t idx, RedisModuleCallReply **key, RedisModuleCallReply **val) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_CallReplyPromiseSetUnblockHandler)(RedisModuleCallReply *reply, RedisModuleOnUnblocked on_unblock, void *private_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CallReplyPromiseAbort)(RedisModuleCallReply *reply, void **private_data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplyAttribute)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_CallReplyLength)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCallReply * (*RedisModule_CallReplyArrayElement)(RedisModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateString)(RedisModuleCtx *ctx, const char *ptr, size_t len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongLong)(RedisModuleCtx *ctx, long long ll) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromULongLong)(RedisModuleCtx *ctx, unsigned long long ull) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromLongDouble)(RedisModuleCtx *ctx, long double ld, int humanfriendly) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromString)(RedisModuleCtx *ctx, const RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromStreamID)(RedisModuleCtx *ctx, const RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringPrintf)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR_PRINTF(2,3) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_StringPtrLen)(const RedisModuleString *str, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithError)(RedisModuleCtx *ctx, const char *err) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithErrorFormat)(RedisModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithSimpleString)(RedisModuleCtx *ctx, const char *msg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithArray)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithMap)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithSet)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithAttribute)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithNullArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithEmptyArray)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetArrayLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetMapLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetSetLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetAttributeLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ReplySetPushLength)(RedisModuleCtx *ctx, long len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithStringBuffer)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithCString)(RedisModuleCtx *ctx, const char *buf) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithEmptyString)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithVerbatimString)(RedisModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithVerbatimStringType)(RedisModuleCtx *ctx, const char *buf, size_t len, const char *ext) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithNull)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithBool)(RedisModuleCtx *ctx, int b) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithLongDouble)(RedisModuleCtx *ctx, long double d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithDouble)(RedisModuleCtx *ctx, double d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithBigNumber)(RedisModuleCtx *ctx, const char *bignum, size_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplyWithCallReply)(RedisModuleCtx *ctx, RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToLongLong)(const RedisModuleString *str, long long *ll) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToULongLong)(const RedisModuleString *str, unsigned long long *ull) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToDouble)(const RedisModuleString *str, double *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToLongDouble)(const RedisModuleString *str, long double *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringToStreamID)(const RedisModuleString *str, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_AutoMemory)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Replicate)(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ReplicateVerbatim)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_CallReplyStringPtr)(RedisModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CreateStringFromCallReply)(RedisModuleCallReply *reply) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DeleteKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnlinkKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringSet)(RedisModuleKey *key, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_StringDMA)(RedisModuleKey *key, size_t *len, int mode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringTruncate)(RedisModuleKey *key, size_t newlen) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_GetExpire)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetExpire)(RedisModuleKey *key, mstime_t expire) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_GetAbsExpire)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetAbsExpire)(RedisModuleKey *key, mstime_t expire) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ResetDataset)(int restart_aof, int async) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_DbSize)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_RandomKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetAdd)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetIncrby)(RedisModuleKey *key, double score, RedisModuleString *ele, int *flagsptr, double *newscore) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetScore)(RedisModuleKey *key, RedisModuleString *ele, double *score) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRem)(RedisModuleKey *key, RedisModuleString *ele, int *deleted) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ZsetRangeStop)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetFirstInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetLastInScoreRange)(RedisModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetFirstInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetLastInLexRange)(RedisModuleKey *key, RedisModuleString *min, RedisModuleString *max) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ZsetRangeCurrentElement)(RedisModuleKey *key, double *score) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangeNext)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangePrev)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ZsetRangeEndReached)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_HashSet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_HashGet)(RedisModuleKey *key, int flags, ...) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamAdd)(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisModuleString **argv, int64_t numfields) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamDelete)(RedisModuleKey *key, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorStart)(RedisModuleKey *key, int flags, RedisModuleStreamID *startid, RedisModuleStreamID *endid) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorStop)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorNextID)(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorNextField)(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StreamIteratorDelete)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_StreamTrimByLength)(RedisModuleKey *key, int flags, long long length) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_StreamTrimByID)(RedisModuleKey *key, int flags, RedisModuleStreamID *id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsKeysPositionRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_KeyAtPos)(RedisModuleCtx *ctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_KeyAtPosWithFlags)(RedisModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsChannelsPositionRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ChannelAtPosWithFlags)(RedisModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_GetClientId)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientUserNameById)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetClientInfoById)(void *ci, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientNameById)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetClientNameById)(uint64_t id, RedisModuleString *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_PublishMessage)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_PublishMessageShard)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetContextFlags)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AvoidReplicaTraffic)(void) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleType * (*RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ModuleTypeReplaceValue)(RedisModuleKey *key, RedisModuleType *mt, void *new_value, void **old_value) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleType * (*RedisModule_ModuleTypeGetType)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_ModuleTypeGetValue)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsIOError)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetModuleOptions)(RedisModuleCtx *ctx, int options) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SignalModifiedKey)(RedisModuleCtx *ctx, RedisModuleString *keyname) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveUnsigned)(RedisModuleIO *io, uint64_t value) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_LoadUnsigned)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveSigned)(RedisModuleIO *io, int64_t value) REDISMODULE_ATTR; -REDISMODULE_API int64_t (*RedisModule_LoadSigned)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_EmitAOF)(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveString)(RedisModuleIO *io, RedisModuleString *s) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveStringBuffer)(RedisModuleIO *io, const char *str, size_t len) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_LoadString)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API char * (*RedisModule_LoadStringBuffer)(RedisModuleIO *io, size_t *lenptr) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveDouble)(RedisModuleIO *io, double value) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_LoadDouble)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveFloat)(RedisModuleIO *io, float value) REDISMODULE_ATTR; -REDISMODULE_API float (*RedisModule_LoadFloat)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SaveLongDouble)(RedisModuleIO *io, long double value) REDISMODULE_ATTR; -REDISMODULE_API long double (*RedisModule_LoadLongDouble)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_LoadDataTypeFromString)(const RedisModuleString *str, const RedisModuleType *mt) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_LoadDataTypeFromStringEncver)(const RedisModuleString *str, const RedisModuleType *mt, int encver) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_SaveDataTypeToString)(RedisModuleCtx *ctx, void *data, const RedisModuleType *mt) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Log)(RedisModuleCtx *ctx, const char *level, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); -REDISMODULE_API void (*RedisModule_LogIOError)(RedisModuleIO *io, const char *levelstr, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); -REDISMODULE_API void (*RedisModule__Assert)(const char *estr, const char *file, int line) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_LatencyAddSample)(const char *event, mstime_t latency) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringAppendBuffer)(RedisModuleCtx *ctx, RedisModuleString *str, const char *buf, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_TrimStringAllocation)(RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RetainString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_HoldString)(RedisModuleCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StringCompare)(const RedisModuleString *a, const RedisModuleString *b) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetContextFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromModuleKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromModuleKey)(RedisModuleKey *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromIO)(RedisModuleIO *io) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetToDbIdFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetToKeyNameFromOptCtx)(RedisModuleKeyOptCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API mstime_t (*RedisModule_Milliseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_MonotonicMicroseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API ustime_t (*RedisModule_Microseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API ustime_t (*RedisModule_CachedMicroseconds)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestAddStringBuffer)(RedisModuleDigest *md, const char *ele, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestAddLongLong)(RedisModuleDigest *md, long long ele) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DigestEndSequence)(RedisModuleDigest *md) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromDigest)(RedisModuleDigest *dig) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromDigest)(RedisModuleDigest *dig) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDict * (*RedisModule_CreateDict)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeDict)(RedisModuleCtx *ctx, RedisModuleDict *d) REDISMODULE_ATTR; -REDISMODULE_API uint64_t (*RedisModule_DictSize)(RedisModuleDict *d) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictSetC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictReplaceC)(RedisModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictSet)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictReplace)(RedisModuleDict *d, RedisModuleString *key, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictGetC)(RedisModuleDict *d, void *key, size_t keylen, int *nokey) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictGet)(RedisModuleDict *d, RedisModuleString *key, int *nokey) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictDelC)(RedisModuleDict *d, void *key, size_t keylen, void *oldval) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictDel)(RedisModuleDict *d, RedisModuleString *key, void *oldval) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStartC)(RedisModuleDict *d, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleDictIter * (*RedisModule_DictIteratorStart)(RedisModuleDict *d, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_DictIteratorStop)(RedisModuleDictIter *di) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictIteratorReseekC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictIteratorReseek)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictNextC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_DictPrevC)(RedisModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_DictNext)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_DictPrev)(RedisModuleCtx *ctx, RedisModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictCompareC)(RedisModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DictCompare)(RedisModuleDictIter *di, const char *op, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterInfoFunc)(RedisModuleCtx *ctx, RedisModuleInfoFunc cb) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RegisterAuthCallback)(RedisModuleCtx *ctx, RedisModuleAuthCallback cb) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddSection)(RedisModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoBeginDictField)(RedisModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoEndDictField)(RedisModuleInfoCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldString)(RedisModuleInfoCtx *ctx, const char *field, RedisModuleString *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldCString)(RedisModuleInfoCtx *ctx, const char *field,const char *value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldDouble)(RedisModuleInfoCtx *ctx, const char *field, double value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldLongLong)(RedisModuleInfoCtx *ctx, const char *field, long long value) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_InfoAddFieldULongLong)(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleServerInfoData * (*RedisModule_GetServerInfo)(RedisModuleCtx *ctx, const char *section) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeServerInfo)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_ServerInfoGetField)(RedisModuleCtx *ctx, RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_ServerInfoGetFieldC)(RedisModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; -REDISMODULE_API long long (*RedisModule_ServerInfoGetFieldSigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_ServerInfoGetFieldUnsigned)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API double (*RedisModule_ServerInfoGetFieldDouble)(RedisModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SubscribeToServerEvent)(RedisModuleCtx *ctx, RedisModuleEvent event, RedisModuleEventCallback callback) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetLRU)(RedisModuleKey *key, mstime_t lru_idle) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetLRU)(RedisModuleKey *key, mstime_t *lru_idle) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetLFU)(RedisModuleKey *key, long long lfu_freq) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetLFU)(RedisModuleKey *key, long long *lfu_freq) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnKeys)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnKeysWithFlags)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata, int flags) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SignalKeyAsReady)(RedisModuleCtx *ctx, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetBlockedClientReadyKey)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleScanCursor * (*RedisModule_ScanCursorCreate)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ScanCursorRestart)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ScanCursorDestroy)(RedisModuleScanCursor *cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Scan)(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanCB fn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ScanKey)(RedisModuleKey *key, RedisModuleScanCursor *cursor, RedisModuleScanKeyCB fn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetContextFlagsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetModuleOptionsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetKeyspaceNotificationFlagsAll)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsSubEventSupported)(RedisModuleEvent event, uint64_t subevent) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetServerVersion)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetTypeMethodVersion)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_Yield)(RedisModuleCtx *ctx, int flags, const char *busy_reply) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClient)(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_BlockClientGetPrivateData)(RedisModuleBlockedClient *blocked_client) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_BlockClientSetPrivateData)(RedisModuleBlockedClient *blocked_client, void *private_data) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_BlockClientOnAuth)(RedisModuleCtx *ctx, RedisModuleAuthCallback reply_callback, void (*free_privdata)(RedisModuleCtx*,void*)) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnblockClient)(RedisModuleBlockedClient *bc, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsBlockedReplyRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_IsBlockedTimeoutRequest)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_GetBlockedClientPrivateData)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleBlockedClient * (*RedisModule_GetBlockedClientHandle)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AbortBlock)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientMeasureTimeStart)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientMeasureTimeEnd)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetThreadSafeContext)(RedisModuleBlockedClient *bc) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCtx * (*RedisModule_GetDetachedThreadSafeContext)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeThreadSafeContext)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ThreadSafeContextLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ThreadSafeContextTryLock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ThreadSafeContextUnlock)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SubscribeToKeyspaceEvents)(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc cb) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AddPostNotificationJob)(RedisModuleCtx *ctx, RedisModulePostNotificationJobFunc callback, void *pd, void (*free_pd)(void*)) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_NotifyKeyspaceEvent)(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetNotifyKeyspaceEvents)(void) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_BlockedClientDisconnected)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RegisterClusterMessageReceiver)(RedisModuleCtx *ctx, uint8_t type, RedisModuleClusterMessageReceiver callback) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SendClusterMessage)(RedisModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetClusterNodeInfo)(RedisModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) REDISMODULE_ATTR; -REDISMODULE_API char ** (*RedisModule_GetClusterNodesList)(RedisModuleCtx *ctx, size_t *numnodes) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeClusterNodesList)(char **ids) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleTimerID (*RedisModule_CreateTimer)(RedisModuleCtx *ctx, mstime_t period, RedisModuleTimerProc callback, void *data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_StopTimer)(RedisModuleCtx *ctx, RedisModuleTimerID id, void **data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetTimerInfo)(RedisModuleCtx *ctx, RedisModuleTimerID id, uint64_t *remaining, void **data) REDISMODULE_ATTR; -REDISMODULE_API const char * (*RedisModule_GetMyClusterID)(void) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_GetClusterSize)(void) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_GetRandomBytes)(unsigned char *dst, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_GetRandomHexChars)(char *dst, size_t len) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetDisconnectCallback)(RedisModuleBlockedClient *bc, RedisModuleDisconnectFunc callback) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetClusterFlags)(RedisModuleCtx *ctx, uint64_t flags) REDISMODULE_ATTR; -REDISMODULE_API unsigned int (*RedisModule_ClusterKeySlot)(RedisModuleString *key) REDISMODULE_ATTR; -REDISMODULE_API const char *(*RedisModule_ClusterCanonicalKeyNameInSlot)(unsigned int slot) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ExportSharedAPI)(RedisModuleCtx *ctx, const char *apiname, void *func) REDISMODULE_ATTR; -REDISMODULE_API void * (*RedisModule_GetSharedAPI)(RedisModuleCtx *ctx, const char *apiname) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleCommandFilter * (*RedisModule_RegisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilterFunc cb, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_UnregisterCommandFilter)(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgsCount)(RedisModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_CommandFilterArgGet)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgInsert)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgReplace)(RedisModuleCommandFilterCtx *fctx, int pos, RedisModuleString *arg) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_CommandFilterArgDelete)(RedisModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API unsigned long long (*RedisModule_CommandFilterGetClientId)(RedisModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_Fork)(RedisModuleForkDoneHandler cb, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SendChildHeartbeat)(double progress) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ExitFromChild)(int retcode) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_KillForkChild)(int child_pid) REDISMODULE_ATTR; -REDISMODULE_API float (*RedisModule_GetUsedMemoryRatio)(void) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSize)(void* ptr) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocUsableSize)(void *ptr) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSizeString)(RedisModuleString* str) REDISMODULE_ATTR; -REDISMODULE_API size_t (*RedisModule_MallocSizeDict)(RedisModuleDict* dict) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleUser * (*RedisModule_CreateModuleUser)(const char *name) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_FreeModuleUser)(RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_SetContextUser)(RedisModuleCtx *ctx, const RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetModuleUserACL)(RedisModuleUser *user, const char* acl) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_SetModuleUserACLString)(RedisModuleCtx * ctx, RedisModuleUser *user, const char* acl, RedisModuleString **error) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetModuleUserACLString)(RedisModuleUser *user) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetCurrentUserName)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleUser * (*RedisModule_GetModuleUserFromUserName)(RedisModuleString *name) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckCommandPermissions)(RedisModuleUser *user, RedisModuleString **argv, int argc) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckKeyPermissions)(RedisModuleUser *user, RedisModuleString *key, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_ACLCheckChannelPermissions)(RedisModuleUser *user, RedisModuleString *ch, int literal) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ACLAddLogEntry)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_ACLAddLogEntryByUserName)(RedisModuleCtx *ctx, RedisModuleString *user, RedisModuleString *object, RedisModuleACLLogEntryReason reason) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AuthenticateClientWithACLUser)(RedisModuleCtx *ctx, const char *name, size_t len, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_AuthenticateClientWithUser)(RedisModuleCtx *ctx, RedisModuleUser *user, RedisModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DeauthenticateAndCloseClient)(RedisModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RedactClientCommandArgument)(RedisModuleCtx *ctx, int pos) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString * (*RedisModule_GetClientCertificate)(RedisModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; -REDISMODULE_API int *(*RedisModule_GetCommandKeys)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) REDISMODULE_ATTR; -REDISMODULE_API int *(*RedisModule_GetCommandKeysWithFlags)(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) REDISMODULE_ATTR; -REDISMODULE_API const char *(*RedisModule_GetCurrentCommandName)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterDefragFunc)(RedisModuleCtx *ctx, RedisModuleDefragFunc func) REDISMODULE_ATTR; -REDISMODULE_API void *(*RedisModule_DefragAlloc)(RedisModuleDefragCtx *ctx, void *ptr) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleString *(*RedisModule_DefragRedisModuleString)(RedisModuleDefragCtx *ctx, RedisModuleString *str) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragShouldStop)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragCursorSet)(RedisModuleDefragCtx *ctx, unsigned long cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_DefragCursorGet)(RedisModuleDefragCtx *ctx, unsigned long *cursor) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_GetDbIdFromDefragCtx)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API const RedisModuleString * (*RedisModule_GetKeyNameFromDefragCtx)(RedisModuleDefragCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopAdd)(int fd, int mask, RedisModuleEventLoopFunc func, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopDel)(int fd, int mask) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_EventLoopAddOneShot)(RedisModuleEventLoopOneShotFunc func, void *user_data) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterBoolConfig)(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedisModuleConfigGetBoolFunc getfn, RedisModuleConfigSetBoolFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterNumericConfig)(RedisModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedisModuleConfigGetNumericFunc getfn, RedisModuleConfigSetNumericFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterStringConfig)(RedisModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedisModuleConfigGetStringFunc getfn, RedisModuleConfigSetStringFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RegisterEnumConfig)(RedisModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedisModuleConfigGetEnumFunc getfn, RedisModuleConfigSetEnumFunc setfn, RedisModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_LoadConfigs)(RedisModuleCtx *ctx) REDISMODULE_ATTR; -REDISMODULE_API RedisModuleRdbStream *(*RedisModule_RdbStreamCreateFromFile)(const char *filename) REDISMODULE_ATTR; -REDISMODULE_API void (*RedisModule_RdbStreamFree)(RedisModuleRdbStream *stream) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RdbLoad)(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) REDISMODULE_ATTR; -REDISMODULE_API int (*RedisModule_RdbSave)(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_Alloc)(size_t bytes) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_TryAlloc)(size_t bytes) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_Realloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_TryRealloc)(void *ptr, size_t bytes) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_Free)(void *ptr) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_Calloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_TryCalloc)(size_t nmemb, size_t size) REDISMODULE_ATTR; +REDISMODULE_API char * (*RedictModule_Strdup)(const char *str) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetApi)(const char *, void *) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CreateCommand)(RedictModuleCtx *ctx, const char *name, RedictModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCommand *(*RedictModule_GetCommand)(RedictModuleCtx *ctx, const char *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CreateSubcommand)(RedictModuleCommand *parent, const char *name, RedictModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetCommandInfo)(RedictModuleCommand *command, const RedictModuleCommandInfo *info) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetCommandACLCategories)(RedictModuleCommand *command, const char *ctgrsflags) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AddACLCategory)(RedictModuleCtx *ctx, const char *name) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SetModuleAttribs)(RedictModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsModuleNameBusy)(const char *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_WrongArity)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithLongLong)(RedictModuleCtx *ctx, long long ll) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetSelectedDb)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SelectDb)(RedictModuleCtx *ctx, int newid) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_KeyExists)(RedictModuleCtx *ctx, RedictModuleString *keyname) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleKey * (*RedictModule_OpenKey)(RedictModuleCtx *ctx, RedictModuleString *keyname, int mode) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetOpenKeyModesAll)(void) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_CloseKey)(RedictModuleKey *kp) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_KeyType)(RedictModuleKey *kp) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_ValueLength)(RedictModuleKey *kp) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ListPush)(RedictModuleKey *kp, int where, RedictModuleString *ele) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_ListPop)(RedictModuleKey *key, int where) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_ListGet)(RedictModuleKey *key, long index) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ListSet)(RedictModuleKey *key, long index, RedictModuleString *value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ListInsert)(RedictModuleKey *key, long index, RedictModuleString *value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ListDelete)(RedictModuleKey *key, long index) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCallReply * (*RedictModule_Call)(RedictModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; +REDISMODULE_API const char * (*RedictModule_CallReplyProto)(RedictModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeCallReply)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CallReplyType)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API long long (*RedictModule_CallReplyInteger)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API double (*RedictModule_CallReplyDouble)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CallReplyBool)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API const char* (*RedictModule_CallReplyBigNumber)(RedictModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; +REDISMODULE_API const char* (*RedictModule_CallReplyVerbatim)(RedictModuleCallReply *reply, size_t *len, const char **format) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCallReply * (*RedictModule_CallReplySetElement)(RedictModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CallReplyMapElement)(RedictModuleCallReply *reply, size_t idx, RedictModuleCallReply **key, RedictModuleCallReply **val) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CallReplyAttributeElement)(RedictModuleCallReply *reply, size_t idx, RedictModuleCallReply **key, RedictModuleCallReply **val) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_CallReplyPromiseSetUnblockHandler)(RedictModuleCallReply *reply, RedictModuleOnUnblocked on_unblock, void *private_data) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CallReplyPromiseAbort)(RedictModuleCallReply *reply, void **private_data) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCallReply * (*RedictModule_CallReplyAttribute)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_CallReplyLength)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCallReply * (*RedictModule_CallReplyArrayElement)(RedictModuleCallReply *reply, size_t idx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateString)(RedictModuleCtx *ctx, const char *ptr, size_t len) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromLongLong)(RedictModuleCtx *ctx, long long ll) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromULongLong)(RedictModuleCtx *ctx, unsigned long long ull) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromDouble)(RedictModuleCtx *ctx, double d) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromLongDouble)(RedictModuleCtx *ctx, long double ld, int humanfriendly) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromString)(RedictModuleCtx *ctx, const RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromStreamID)(RedictModuleCtx *ctx, const RedictModuleStreamID *id) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringPrintf)(RedictModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR_PRINTF(2,3) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeString)(RedictModuleCtx *ctx, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API const char * (*RedictModule_StringPtrLen)(const RedictModuleString *str, size_t *len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithError)(RedictModuleCtx *ctx, const char *err) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithErrorFormat)(RedictModuleCtx *ctx, const char *fmt, ...) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithSimpleString)(RedictModuleCtx *ctx, const char *msg) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithArray)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithMap)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithSet)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithAttribute)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithNullArray)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithEmptyArray)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ReplySetArrayLength)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ReplySetMapLength)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ReplySetSetLength)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ReplySetAttributeLength)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ReplySetPushLength)(RedictModuleCtx *ctx, long len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithStringBuffer)(RedictModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithCString)(RedictModuleCtx *ctx, const char *buf) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithString)(RedictModuleCtx *ctx, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithEmptyString)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithVerbatimString)(RedictModuleCtx *ctx, const char *buf, size_t len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithVerbatimStringType)(RedictModuleCtx *ctx, const char *buf, size_t len, const char *ext) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithNull)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithBool)(RedictModuleCtx *ctx, int b) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithLongDouble)(RedictModuleCtx *ctx, long double d) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithDouble)(RedictModuleCtx *ctx, double d) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithBigNumber)(RedictModuleCtx *ctx, const char *bignum, size_t len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplyWithCallReply)(RedictModuleCtx *ctx, RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringToLongLong)(const RedictModuleString *str, long long *ll) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringToULongLong)(const RedictModuleString *str, unsigned long long *ull) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringToDouble)(const RedictModuleString *str, double *d) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringToLongDouble)(const RedictModuleString *str, long double *d) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringToStreamID)(const RedictModuleString *str, RedictModuleStreamID *id) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_AutoMemory)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_Replicate)(RedictModuleCtx *ctx, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ReplicateVerbatim)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API const char * (*RedictModule_CallReplyStringPtr)(RedictModuleCallReply *reply, size_t *len) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CreateStringFromCallReply)(RedictModuleCallReply *reply) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DeleteKey)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_UnlinkKey)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringSet)(RedictModuleKey *key, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API char * (*RedictModule_StringDMA)(RedictModuleKey *key, size_t *len, int mode) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringTruncate)(RedictModuleKey *key, size_t newlen) REDISMODULE_ATTR; +REDISMODULE_API mstime_t (*RedictModule_GetExpire)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetExpire)(RedictModuleKey *key, mstime_t expire) REDISMODULE_ATTR; +REDISMODULE_API mstime_t (*RedictModule_GetAbsExpire)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetAbsExpire)(RedictModuleKey *key, mstime_t expire) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ResetDataset)(int restart_aof, int async) REDISMODULE_ATTR; +REDISMODULE_API unsigned long long (*RedictModule_DbSize)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_RandomKey)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetAdd)(RedictModuleKey *key, double score, RedictModuleString *ele, int *flagsptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetIncrby)(RedictModuleKey *key, double score, RedictModuleString *ele, int *flagsptr, double *newscore) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetScore)(RedictModuleKey *key, RedictModuleString *ele, double *score) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetRem)(RedictModuleKey *key, RedictModuleString *ele, int *deleted) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ZsetRangeStop)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetFirstInScoreRange)(RedictModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetLastInScoreRange)(RedictModuleKey *key, double min, double max, int minex, int maxex) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetFirstInLexRange)(RedictModuleKey *key, RedictModuleString *min, RedictModuleString *max) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetLastInLexRange)(RedictModuleKey *key, RedictModuleString *min, RedictModuleString *max) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_ZsetRangeCurrentElement)(RedictModuleKey *key, double *score) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetRangeNext)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetRangePrev)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ZsetRangeEndReached)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_HashSet)(RedictModuleKey *key, int flags, ...) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_HashGet)(RedictModuleKey *key, int flags, ...) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamAdd)(RedictModuleKey *key, int flags, RedictModuleStreamID *id, RedictModuleString **argv, int64_t numfields) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamDelete)(RedictModuleKey *key, RedictModuleStreamID *id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamIteratorStart)(RedictModuleKey *key, int flags, RedictModuleStreamID *startid, RedictModuleStreamID *endid) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamIteratorStop)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamIteratorNextID)(RedictModuleKey *key, RedictModuleStreamID *id, long *numfields) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamIteratorNextField)(RedictModuleKey *key, RedictModuleString **field_ptr, RedictModuleString **value_ptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StreamIteratorDelete)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API long long (*RedictModule_StreamTrimByLength)(RedictModuleKey *key, int flags, long long length) REDISMODULE_ATTR; +REDISMODULE_API long long (*RedictModule_StreamTrimByID)(RedictModuleKey *key, int flags, RedictModuleStreamID *id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsKeysPositionRequest)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_KeyAtPos)(RedictModuleCtx *ctx, int pos) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_KeyAtPosWithFlags)(RedictModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsChannelsPositionRequest)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ChannelAtPosWithFlags)(RedictModuleCtx *ctx, int pos, int flags) REDISMODULE_ATTR; +REDISMODULE_API unsigned long long (*RedictModule_GetClientId)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetClientUserNameById)(RedictModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetClientInfoById)(void *ci, uint64_t id) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetClientNameById)(RedictModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetClientNameById)(uint64_t id, RedictModuleString *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_PublishMessage)(RedictModuleCtx *ctx, RedictModuleString *channel, RedictModuleString *message) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_PublishMessageShard)(RedictModuleCtx *ctx, RedictModuleString *channel, RedictModuleString *message) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetContextFlags)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AvoidReplicaTraffic)(void) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_PoolAlloc)(RedictModuleCtx *ctx, size_t bytes) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleType * (*RedictModule_CreateDataType)(RedictModuleCtx *ctx, const char *name, int encver, RedictModuleTypeMethods *typemethods) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ModuleTypeSetValue)(RedictModuleKey *key, RedictModuleType *mt, void *value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ModuleTypeReplaceValue)(RedictModuleKey *key, RedictModuleType *mt, void *new_value, void **old_value) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleType * (*RedictModule_ModuleTypeGetType)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_ModuleTypeGetValue)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsIOError)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SetModuleOptions)(RedictModuleCtx *ctx, int options) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SignalModifiedKey)(RedictModuleCtx *ctx, RedictModuleString *keyname) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveUnsigned)(RedictModuleIO *io, uint64_t value) REDISMODULE_ATTR; +REDISMODULE_API uint64_t (*RedictModule_LoadUnsigned)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveSigned)(RedictModuleIO *io, int64_t value) REDISMODULE_ATTR; +REDISMODULE_API int64_t (*RedictModule_LoadSigned)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_EmitAOF)(RedictModuleIO *io, const char *cmdname, const char *fmt, ...) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveString)(RedictModuleIO *io, RedictModuleString *s) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveStringBuffer)(RedictModuleIO *io, const char *str, size_t len) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_LoadString)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API char * (*RedictModule_LoadStringBuffer)(RedictModuleIO *io, size_t *lenptr) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveDouble)(RedictModuleIO *io, double value) REDISMODULE_ATTR; +REDISMODULE_API double (*RedictModule_LoadDouble)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveFloat)(RedictModuleIO *io, float value) REDISMODULE_ATTR; +REDISMODULE_API float (*RedictModule_LoadFloat)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SaveLongDouble)(RedictModuleIO *io, long double value) REDISMODULE_ATTR; +REDISMODULE_API long double (*RedictModule_LoadLongDouble)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_LoadDataTypeFromString)(const RedictModuleString *str, const RedictModuleType *mt) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_LoadDataTypeFromStringEncver)(const RedictModuleString *str, const RedictModuleType *mt, int encver) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_SaveDataTypeToString)(RedictModuleCtx *ctx, void *data, const RedictModuleType *mt) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_Log)(RedictModuleCtx *ctx, const char *level, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); +REDISMODULE_API void (*RedictModule_LogIOError)(RedictModuleIO *io, const char *levelstr, const char *fmt, ...) REDISMODULE_ATTR REDISMODULE_ATTR_PRINTF(3,4); +REDISMODULE_API void (*RedictModule__Assert)(const char *estr, const char *file, int line) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_LatencyAddSample)(const char *event, mstime_t latency) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringAppendBuffer)(RedictModuleCtx *ctx, RedictModuleString *str, const char *buf, size_t len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_TrimStringAllocation)(RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_RetainString)(RedictModuleCtx *ctx, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_HoldString)(RedictModuleCtx *ctx, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StringCompare)(const RedictModuleString *a, const RedictModuleString *b) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCtx * (*RedictModule_GetContextFromIO)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetKeyNameFromIO)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetKeyNameFromModuleKey)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetDbIdFromModuleKey)(RedictModuleKey *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetDbIdFromIO)(RedictModuleIO *io) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetDbIdFromOptCtx)(RedictModuleKeyOptCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetToDbIdFromOptCtx)(RedictModuleKeyOptCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetKeyNameFromOptCtx)(RedictModuleKeyOptCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetToKeyNameFromOptCtx)(RedictModuleKeyOptCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API mstime_t (*RedictModule_Milliseconds)(void) REDISMODULE_ATTR; +REDISMODULE_API uint64_t (*RedictModule_MonotonicMicroseconds)(void) REDISMODULE_ATTR; +REDISMODULE_API ustime_t (*RedictModule_Microseconds)(void) REDISMODULE_ATTR; +REDISMODULE_API ustime_t (*RedictModule_CachedMicroseconds)(void) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_DigestAddStringBuffer)(RedictModuleDigest *md, const char *ele, size_t len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_DigestAddLongLong)(RedictModuleDigest *md, long long ele) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_DigestEndSequence)(RedictModuleDigest *md) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetDbIdFromDigest)(RedictModuleDigest *dig) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetKeyNameFromDigest)(RedictModuleDigest *dig) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleDict * (*RedictModule_CreateDict)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeDict)(RedictModuleCtx *ctx, RedictModuleDict *d) REDISMODULE_ATTR; +REDISMODULE_API uint64_t (*RedictModule_DictSize)(RedictModuleDict *d) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictSetC)(RedictModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictReplaceC)(RedictModuleDict *d, void *key, size_t keylen, void *ptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictSet)(RedictModuleDict *d, RedictModuleString *key, void *ptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictReplace)(RedictModuleDict *d, RedictModuleString *key, void *ptr) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_DictGetC)(RedictModuleDict *d, void *key, size_t keylen, int *nokey) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_DictGet)(RedictModuleDict *d, RedictModuleString *key, int *nokey) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictDelC)(RedictModuleDict *d, void *key, size_t keylen, void *oldval) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictDel)(RedictModuleDict *d, RedictModuleString *key, void *oldval) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleDictIter * (*RedictModule_DictIteratorStartC)(RedictModuleDict *d, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleDictIter * (*RedictModule_DictIteratorStart)(RedictModuleDict *d, const char *op, RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_DictIteratorStop)(RedictModuleDictIter *di) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictIteratorReseekC)(RedictModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictIteratorReseek)(RedictModuleDictIter *di, const char *op, RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_DictNextC)(RedictModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_DictPrevC)(RedictModuleDictIter *di, size_t *keylen, void **dataptr) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_DictNext)(RedictModuleCtx *ctx, RedictModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_DictPrev)(RedictModuleCtx *ctx, RedictModuleDictIter *di, void **dataptr) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictCompareC)(RedictModuleDictIter *di, const char *op, void *key, size_t keylen) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DictCompare)(RedictModuleDictIter *di, const char *op, RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterInfoFunc)(RedictModuleCtx *ctx, RedictModuleInfoFunc cb) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_RegisterAuthCallback)(RedictModuleCtx *ctx, RedictModuleAuthCallback cb) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddSection)(RedictModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoBeginDictField)(RedictModuleInfoCtx *ctx, const char *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoEndDictField)(RedictModuleInfoCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddFieldString)(RedictModuleInfoCtx *ctx, const char *field, RedictModuleString *value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddFieldCString)(RedictModuleInfoCtx *ctx, const char *field,const char *value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddFieldDouble)(RedictModuleInfoCtx *ctx, const char *field, double value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddFieldLongLong)(RedictModuleInfoCtx *ctx, const char *field, long long value) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_InfoAddFieldULongLong)(RedictModuleInfoCtx *ctx, const char *field, unsigned long long value) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleServerInfoData * (*RedictModule_GetServerInfo)(RedictModuleCtx *ctx, const char *section) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeServerInfo)(RedictModuleCtx *ctx, RedictModuleServerInfoData *data) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_ServerInfoGetField)(RedictModuleCtx *ctx, RedictModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; +REDISMODULE_API const char * (*RedictModule_ServerInfoGetFieldC)(RedictModuleServerInfoData *data, const char* field) REDISMODULE_ATTR; +REDISMODULE_API long long (*RedictModule_ServerInfoGetFieldSigned)(RedictModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; +REDISMODULE_API unsigned long long (*RedictModule_ServerInfoGetFieldUnsigned)(RedictModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; +REDISMODULE_API double (*RedictModule_ServerInfoGetFieldDouble)(RedictModuleServerInfoData *data, const char* field, int *out_err) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SubscribeToServerEvent)(RedictModuleCtx *ctx, RedictModuleEvent event, RedictModuleEventCallback callback) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetLRU)(RedictModuleKey *key, mstime_t lru_idle) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetLRU)(RedictModuleKey *key, mstime_t *lru_idle) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetLFU)(RedictModuleKey *key, long long lfu_freq) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetLFU)(RedictModuleKey *key, long long *lfu_freq) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleBlockedClient * (*RedictModule_BlockClientOnKeys)(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), long long timeout_ms, RedictModuleString **keys, int numkeys, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleBlockedClient * (*RedictModule_BlockClientOnKeysWithFlags)(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), long long timeout_ms, RedictModuleString **keys, int numkeys, void *privdata, int flags) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SignalKeyAsReady)(RedictModuleCtx *ctx, RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetBlockedClientReadyKey)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleScanCursor * (*RedictModule_ScanCursorCreate)(void) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ScanCursorRestart)(RedictModuleScanCursor *cursor) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ScanCursorDestroy)(RedictModuleScanCursor *cursor) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_Scan)(RedictModuleCtx *ctx, RedictModuleScanCursor *cursor, RedictModuleScanCB fn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ScanKey)(RedictModuleKey *key, RedictModuleScanCursor *cursor, RedictModuleScanKeyCB fn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetContextFlagsAll)(void) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetModuleOptionsAll)(void) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetKeyspaceNotificationFlagsAll)(void) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsSubEventSupported)(RedictModuleEvent event, uint64_t subevent) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetServerVersion)(void) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetTypeMethodVersion)(void) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_Yield)(RedictModuleCtx *ctx, int flags, const char *busy_reply) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleBlockedClient * (*RedictModule_BlockClient)(RedictModuleCtx *ctx, RedictModuleCmdFunc reply_callback, RedictModuleCmdFunc timeout_callback, void (*free_privdata)(RedictModuleCtx*,void*), long long timeout_ms) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_BlockClientGetPrivateData)(RedictModuleBlockedClient *blocked_client) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_BlockClientSetPrivateData)(RedictModuleBlockedClient *blocked_client, void *private_data) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleBlockedClient * (*RedictModule_BlockClientOnAuth)(RedictModuleCtx *ctx, RedictModuleAuthCallback reply_callback, void (*free_privdata)(RedictModuleCtx*,void*)) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_UnblockClient)(RedictModuleBlockedClient *bc, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsBlockedReplyRequest)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_IsBlockedTimeoutRequest)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_GetBlockedClientPrivateData)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleBlockedClient * (*RedictModule_GetBlockedClientHandle)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AbortBlock)(RedictModuleBlockedClient *bc) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_BlockedClientMeasureTimeStart)(RedictModuleBlockedClient *bc) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_BlockedClientMeasureTimeEnd)(RedictModuleBlockedClient *bc) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCtx * (*RedictModule_GetThreadSafeContext)(RedictModuleBlockedClient *bc) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCtx * (*RedictModule_GetDetachedThreadSafeContext)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeThreadSafeContext)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ThreadSafeContextLock)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ThreadSafeContextTryLock)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ThreadSafeContextUnlock)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SubscribeToKeyspaceEvents)(RedictModuleCtx *ctx, int types, RedictModuleNotificationFunc cb) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AddPostNotificationJob)(RedictModuleCtx *ctx, RedictModulePostNotificationJobFunc callback, void *pd, void (*free_pd)(void*)) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_NotifyKeyspaceEvent)(RedictModuleCtx *ctx, int type, const char *event, RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetNotifyKeyspaceEvents)(void) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_BlockedClientDisconnected)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_RegisterClusterMessageReceiver)(RedictModuleCtx *ctx, uint8_t type, RedictModuleClusterMessageReceiver callback) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SendClusterMessage)(RedictModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetClusterNodeInfo)(RedictModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) REDISMODULE_ATTR; +REDISMODULE_API char ** (*RedictModule_GetClusterNodesList)(RedictModuleCtx *ctx, size_t *numnodes) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeClusterNodesList)(char **ids) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleTimerID (*RedictModule_CreateTimer)(RedictModuleCtx *ctx, mstime_t period, RedictModuleTimerProc callback, void *data) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_StopTimer)(RedictModuleCtx *ctx, RedictModuleTimerID id, void **data) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetTimerInfo)(RedictModuleCtx *ctx, RedictModuleTimerID id, uint64_t *remaining, void **data) REDISMODULE_ATTR; +REDISMODULE_API const char * (*RedictModule_GetMyClusterID)(void) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_GetClusterSize)(void) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_GetRandomBytes)(unsigned char *dst, size_t len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_GetRandomHexChars)(char *dst, size_t len) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SetDisconnectCallback)(RedictModuleBlockedClient *bc, RedictModuleDisconnectFunc callback) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SetClusterFlags)(RedictModuleCtx *ctx, uint64_t flags) REDISMODULE_ATTR; +REDISMODULE_API unsigned int (*RedictModule_ClusterKeySlot)(RedictModuleString *key) REDISMODULE_ATTR; +REDISMODULE_API const char *(*RedictModule_ClusterCanonicalKeyNameInSlot)(unsigned int slot) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ExportSharedAPI)(RedictModuleCtx *ctx, const char *apiname, void *func) REDISMODULE_ATTR; +REDISMODULE_API void * (*RedictModule_GetSharedAPI)(RedictModuleCtx *ctx, const char *apiname) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleCommandFilter * (*RedictModule_RegisterCommandFilter)(RedictModuleCtx *ctx, RedictModuleCommandFilterFunc cb, int flags) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_UnregisterCommandFilter)(RedictModuleCtx *ctx, RedictModuleCommandFilter *filter) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CommandFilterArgsCount)(RedictModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_CommandFilterArgGet)(RedictModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CommandFilterArgInsert)(RedictModuleCommandFilterCtx *fctx, int pos, RedictModuleString *arg) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CommandFilterArgReplace)(RedictModuleCommandFilterCtx *fctx, int pos, RedictModuleString *arg) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_CommandFilterArgDelete)(RedictModuleCommandFilterCtx *fctx, int pos) REDISMODULE_ATTR; +REDISMODULE_API unsigned long long (*RedictModule_CommandFilterGetClientId)(RedictModuleCommandFilterCtx *fctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_Fork)(RedictModuleForkDoneHandler cb, void *user_data) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SendChildHeartbeat)(double progress) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ExitFromChild)(int retcode) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_KillForkChild)(int child_pid) REDISMODULE_ATTR; +REDISMODULE_API float (*RedictModule_GetUsedMemoryRatio)(void) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_MallocSize)(void* ptr) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_MallocUsableSize)(void *ptr) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_MallocSizeString)(RedictModuleString* str) REDISMODULE_ATTR; +REDISMODULE_API size_t (*RedictModule_MallocSizeDict)(RedictModuleDict* dict) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleUser * (*RedictModule_CreateModuleUser)(const char *name) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_FreeModuleUser)(RedictModuleUser *user) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_SetContextUser)(RedictModuleCtx *ctx, const RedictModuleUser *user) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetModuleUserACL)(RedictModuleUser *user, const char* acl) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_SetModuleUserACLString)(RedictModuleCtx * ctx, RedictModuleUser *user, const char* acl, RedictModuleString **error) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetModuleUserACLString)(RedictModuleUser *user) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetCurrentUserName)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleUser * (*RedictModule_GetModuleUserFromUserName)(RedictModuleString *name) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ACLCheckCommandPermissions)(RedictModuleUser *user, RedictModuleString **argv, int argc) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ACLCheckKeyPermissions)(RedictModuleUser *user, RedictModuleString *key, int flags) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_ACLCheckChannelPermissions)(RedictModuleUser *user, RedictModuleString *ch, int literal) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ACLAddLogEntry)(RedictModuleCtx *ctx, RedictModuleUser *user, RedictModuleString *object, RedictModuleACLLogEntryReason reason) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_ACLAddLogEntryByUserName)(RedictModuleCtx *ctx, RedictModuleString *user, RedictModuleString *object, RedictModuleACLLogEntryReason reason) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AuthenticateClientWithACLUser)(RedictModuleCtx *ctx, const char *name, size_t len, RedictModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_AuthenticateClientWithUser)(RedictModuleCtx *ctx, RedictModuleUser *user, RedictModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DeauthenticateAndCloseClient)(RedictModuleCtx *ctx, uint64_t client_id) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RedactClientCommandArgument)(RedictModuleCtx *ctx, int pos) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString * (*RedictModule_GetClientCertificate)(RedictModuleCtx *ctx, uint64_t id) REDISMODULE_ATTR; +REDISMODULE_API int *(*RedictModule_GetCommandKeys)(RedictModuleCtx *ctx, RedictModuleString **argv, int argc, int *num_keys) REDISMODULE_ATTR; +REDISMODULE_API int *(*RedictModule_GetCommandKeysWithFlags)(RedictModuleCtx *ctx, RedictModuleString **argv, int argc, int *num_keys, int **out_flags) REDISMODULE_ATTR; +REDISMODULE_API const char *(*RedictModule_GetCurrentCommandName)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterDefragFunc)(RedictModuleCtx *ctx, RedictModuleDefragFunc func) REDISMODULE_ATTR; +REDISMODULE_API void *(*RedictModule_DefragAlloc)(RedictModuleDefragCtx *ctx, void *ptr) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleString *(*RedictModule_DefragRedictModuleString)(RedictModuleDefragCtx *ctx, RedictModuleString *str) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DefragShouldStop)(RedictModuleDefragCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DefragCursorSet)(RedictModuleDefragCtx *ctx, unsigned long cursor) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_DefragCursorGet)(RedictModuleDefragCtx *ctx, unsigned long *cursor) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_GetDbIdFromDefragCtx)(RedictModuleDefragCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API const RedictModuleString * (*RedictModule_GetKeyNameFromDefragCtx)(RedictModuleDefragCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_EventLoopAdd)(int fd, int mask, RedictModuleEventLoopFunc func, void *user_data) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_EventLoopDel)(int fd, int mask) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_EventLoopAddOneShot)(RedictModuleEventLoopOneShotFunc func, void *user_data) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterBoolConfig)(RedictModuleCtx *ctx, const char *name, int default_val, unsigned int flags, RedictModuleConfigGetBoolFunc getfn, RedictModuleConfigSetBoolFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterNumericConfig)(RedictModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, RedictModuleConfigGetNumericFunc getfn, RedictModuleConfigSetNumericFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterStringConfig)(RedictModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, RedictModuleConfigGetStringFunc getfn, RedictModuleConfigSetStringFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RegisterEnumConfig)(RedictModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, RedictModuleConfigGetEnumFunc getfn, RedictModuleConfigSetEnumFunc setfn, RedictModuleConfigApplyFunc applyfn, void *privdata) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_LoadConfigs)(RedictModuleCtx *ctx) REDISMODULE_ATTR; +REDISMODULE_API RedictModuleRdbStream *(*RedictModule_RdbStreamCreateFromFile)(const char *filename) REDISMODULE_ATTR; +REDISMODULE_API void (*RedictModule_RdbStreamFree)(RedictModuleRdbStream *stream) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RdbLoad)(RedictModuleCtx *ctx, RedictModuleRdbStream *stream, int flags) REDISMODULE_ATTR; +REDISMODULE_API int (*RedictModule_RdbSave)(RedictModuleCtx *ctx, RedictModuleRdbStream *stream, int flags) REDISMODULE_ATTR; -#define RedisModule_IsAOFClient(id) ((id) == UINT64_MAX) +#define RedictModule_IsAOFClient(id) ((id) == UINT64_MAX) /* This is included inline inside each Redis module. */ -static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR_UNUSED; -static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int apiver) { +static int RedictModule_Init(RedictModuleCtx *ctx, const char *name, int ver, int apiver) REDISMODULE_ATTR_UNUSED; +static int RedictModule_Init(RedictModuleCtx *ctx, const char *name, int ver, int apiver) { void *getapifuncptr = ((void**)ctx)[0]; - RedisModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; + RedictModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; REDISMODULE_GET_API(Alloc); REDISMODULE_GET_API(TryAlloc); REDISMODULE_GET_API(Calloc); @@ -1668,7 +1668,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int REDISMODULE_GET_API(GetCurrentCommandName); REDISMODULE_GET_API(RegisterDefragFunc); REDISMODULE_GET_API(DefragAlloc); - REDISMODULE_GET_API(DefragRedisModuleString); + REDISMODULE_GET_API(DefragRedictModuleString); REDISMODULE_GET_API(DefragShouldStop); REDISMODULE_GET_API(DefragCursorSet); REDISMODULE_GET_API(DefragCursorGet); @@ -1687,12 +1687,12 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int REDISMODULE_GET_API(RdbLoad); REDISMODULE_GET_API(RdbSave); - if (RedisModule_IsModuleNameBusy && RedisModule_IsModuleNameBusy(name)) return REDISMODULE_ERR; - RedisModule_SetModuleAttribs(ctx,name,ver,apiver); + if (RedictModule_IsModuleNameBusy && RedictModule_IsModuleNameBusy(name)) return REDISMODULE_ERR; + RedictModule_SetModuleAttribs(ctx,name,ver,apiver); return REDISMODULE_OK; } -#define RedisModule_Assert(_e) ((_e)?(void)0 : (RedisModule__Assert(#_e,__FILE__,__LINE__),exit(1))) +#define RedictModule_Assert(_e) ((_e)?(void)0 : (RedictModule__Assert(#_e,__FILE__,__LINE__),exit(1))) #define RMAPI_FUNC_SUPPORTED(func) (func != NULL) diff --git a/src/server.c b/src/server.c index 114909bcb..d224e96c3 100644 --- a/src/server.c +++ b/src/server.c @@ -546,7 +546,7 @@ dictType objToDictDictType = { }; /* Modules system dictionary type. Keys are module name, - * values are pointer to RedisModule struct. */ + * values are pointer to RedictModule struct. */ dictType modulesDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ @@ -1501,7 +1501,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { } /* Fire the cron loop modules event. */ - RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz}; + RedictModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz}; moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP, 0, &ei); diff --git a/src/server.h b/src/server.h index b0d2c4b9f..66b77a53d 100644 --- a/src/server.h +++ b/src/server.h @@ -711,12 +711,12 @@ typedef enum { #define REDISMODULE_AUX_BEFORE_RDB (1<<0) #define REDISMODULE_AUX_AFTER_RDB (1<<1) -struct RedisModule; -struct RedisModuleIO; -struct RedisModuleDigest; -struct RedisModuleCtx; +struct RedictModule; +struct RedictModuleIO; +struct RedictModuleDigest; +struct RedictModuleCtx; struct moduleLoadQueueEntry; -struct RedisModuleKeyOptCtx; +struct RedictModuleKeyOptCtx; struct RedictModuleCommand; struct clusterState; @@ -724,31 +724,31 @@ struct clusterState; * to serialize and deserialize the value in the RDB file, rewrite the AOF * log, create the digest for "DEBUG DIGEST", and free the value when a key * is deleted. */ -typedef void *(*moduleTypeLoadFunc)(struct RedisModuleIO *io, int encver); -typedef void (*moduleTypeSaveFunc)(struct RedisModuleIO *io, void *value); -typedef int (*moduleTypeAuxLoadFunc)(struct RedisModuleIO *rdb, int encver, int when); -typedef void (*moduleTypeAuxSaveFunc)(struct RedisModuleIO *rdb, int when); -typedef void (*moduleTypeRewriteFunc)(struct RedisModuleIO *io, struct redictObject *key, void *value); -typedef void (*moduleTypeDigestFunc)(struct RedisModuleDigest *digest, void *value); +typedef void *(*moduleTypeLoadFunc)(struct RedictModuleIO *io, int encver); +typedef void (*moduleTypeSaveFunc)(struct RedictModuleIO *io, void *value); +typedef int (*moduleTypeAuxLoadFunc)(struct RedictModuleIO *rdb, int encver, int when); +typedef void (*moduleTypeAuxSaveFunc)(struct RedictModuleIO *rdb, int when); +typedef void (*moduleTypeRewriteFunc)(struct RedictModuleIO *io, struct redictObject *key, void *value); +typedef void (*moduleTypeDigestFunc)(struct RedictModuleDigest *digest, void *value); typedef size_t (*moduleTypeMemUsageFunc)(const void *value); typedef void (*moduleTypeFreeFunc)(void *value); typedef size_t (*moduleTypeFreeEffortFunc)(struct redictObject *key, const void *value); typedef void (*moduleTypeUnlinkFunc)(struct redictObject *key, void *value); typedef void *(*moduleTypeCopyFunc)(struct redictObject *fromkey, struct redictObject *tokey, const void *value); -typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct redictObject *key, void **value); -typedef size_t (*moduleTypeMemUsageFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value, size_t sample_size); -typedef void (*moduleTypeFreeFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value); -typedef size_t (*moduleTypeFreeEffortFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value); -typedef void (*moduleTypeUnlinkFunc2)(struct RedisModuleKeyOptCtx *ctx, void *value); -typedef void *(*moduleTypeCopyFunc2)(struct RedisModuleKeyOptCtx *ctx, const void *value); -typedef int (*moduleTypeAuthCallback)(struct RedisModuleCtx *ctx, void *username, void *password, const char **err); +typedef int (*moduleTypeDefragFunc)(struct RedictModuleDefragCtx *ctx, struct redictObject *key, void **value); +typedef size_t (*moduleTypeMemUsageFunc2)(struct RedictModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*moduleTypeFreeFunc2)(struct RedictModuleKeyOptCtx *ctx, void *value); +typedef size_t (*moduleTypeFreeEffortFunc2)(struct RedictModuleKeyOptCtx *ctx, const void *value); +typedef void (*moduleTypeUnlinkFunc2)(struct RedictModuleKeyOptCtx *ctx, void *value); +typedef void *(*moduleTypeCopyFunc2)(struct RedictModuleKeyOptCtx *ctx, const void *value); +typedef int (*moduleTypeAuthCallback)(struct RedictModuleCtx *ctx, void *username, void *password, const char **err); /* The module type, which is referenced in each value of a given type, defines * the methods and links to the module exporting the type. */ -typedef struct RedisModuleType { +typedef struct RedictModuleType { uint64_t id; /* Higher 54 bits of type ID + 10 lower bits of encoding ver. */ - struct RedisModule *module; + struct RedictModule *module; moduleTypeLoadFunc rdb_load; moduleTypeSaveFunc rdb_save; moduleTypeRewriteFunc aof_rewrite; @@ -791,7 +791,7 @@ typedef struct moduleValue { } moduleValue; /* This structure represents a module inside the system. */ -struct RedisModule { +struct RedictModule { void *handle; /* Module dlopen() handle. */ char *name; /* Module name. */ int ver; /* Module version. We use just progressive integers. */ @@ -805,25 +805,25 @@ struct RedisModule { int in_call; /* RM_Call() nesting level */ int in_hook; /* Hooks callback nesting level for this module (0 or 1). */ int options; /* Module options and capabilities. */ - int blocked_clients; /* Count of RedisModuleBlockedClient in this module. */ - RedisModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */ - RedisModuleDefragFunc defrag_cb; /* Callback for global data defrag. */ + int blocked_clients; /* Count of RedictModuleBlockedClient in this module. */ + RedictModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */ + RedictModuleDefragFunc defrag_cb; /* Callback for global data defrag. */ struct moduleLoadQueueEntry *loadmod; /* Module load arguments for config rewrite. */ int num_commands_with_acl_categories; /* Number of commands in this module included in acl categories */ int onload; /* Flag to identify if the call is being made from Onload (0 or 1) */ size_t num_acl_categories_added; /* Number of acl categories added by this module. */ }; -typedef struct RedisModule RedisModule; +typedef struct RedictModule RedictModule; /* This is a wrapper for the 'rio' streams used inside rdb.c in Redis, so that * the user does not have to take the total count of the written bytes nor * to care about error conditions. */ -struct RedisModuleIO { +struct RedictModuleIO { size_t bytes; /* Bytes read / written so far. */ rio *rio; /* Rio stream. */ moduleType *type; /* Module type doing the operation. */ int error; /* True if error condition happened. */ - struct RedisModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ + struct RedictModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ struct redictObject *key; /* Optional name of key processed */ int dbid; /* The dbid of the key being processed, -1 when unknown. */ sds pre_flush_buffer; /* A buffer that should be flushed before next write operation @@ -848,7 +848,7 @@ struct RedisModuleIO { * a data structure, so that a digest can be created in a way that correctly * reflects the values. See the DEBUG DIGEST command implementation for more * background. */ -struct RedisModuleDigest { +struct RedictModuleDigest { unsigned char o[20]; /* Ordered elements. */ unsigned char x[20]; /* Xored elements. */ struct redictObject *key; /* Optional name of key processed */ @@ -1019,11 +1019,11 @@ typedef struct blockingState { long long reploffset; /* Replication offset to reach. */ /* BLOCKED_MODULE */ - void *module_blocked_handle; /* RedisModuleBlockedClient structure. + void *module_blocked_handle; /* RedictModuleBlockedClient structure. which is opaque for the Redict core, only handled in module.c. */ - void *async_rm_call_handle; /* RedisModuleAsyncRMCallPromise structure. + void *async_rm_call_handle; /* RedictModuleAsyncRMCallPromise structure. which is opaque for the Redict core, only handled in module.c. */ } blockingState; @@ -1210,13 +1210,13 @@ typedef struct client { listNode *client_list_node; /* list node in client list */ listNode *postponed_list_node; /* list node within the postponed list */ listNode *pending_read_list_node; /* list node in clients pending read list */ - void *module_blocked_client; /* Pointer to the RedisModuleBlockedClient associated with this + void *module_blocked_client; /* Pointer to the RedictModuleBlockedClient associated with this * client. This is set in case of module authentication before the * unblocked client is reprocessed to handle reply callbacks. */ void *module_auth_ctx; /* Ongoing / attempted module based auth callback's ctx. * This is only tracked within the context of the command attempting * authentication. If not NULL, it means module auth is in progress. */ - RedisModuleUserChangedFunc auth_callback; /* Module callback to execute + RedictModuleUserChangedFunc auth_callback; /* Module callback to execute * when the authenticated user * changes. */ void *auth_callback_privdata; /* Private data that is passed when the auth @@ -2091,7 +2091,7 @@ typedef struct { * 2. keynum: there's an arg that contains the number of key args somewhere before the keys themselves */ -/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecBeginSearchType */ +/* WARNING! Must be synced with generate-command-code.py and RedictModuleKeySpecBeginSearchType */ typedef enum { KSPEC_BS_INVALID = 0, /* Must be 0 */ KSPEC_BS_UNKNOWN, @@ -2099,7 +2099,7 @@ typedef enum { KSPEC_BS_KEYWORD } kspec_bs_type; -/* WARNING! Must be synced with generate-command-code.py and RedisModuleKeySpecFindKeysType */ +/* WARNING! Must be synced with generate-command-code.py and RedictModuleKeySpecFindKeysType */ typedef enum { KSPEC_FK_INVALID = 0, /* Must be 0 */ KSPEC_FK_UNKNOWN, @@ -2107,7 +2107,7 @@ typedef enum { KSPEC_FK_KEYNUM } kspec_fk_type; -/* WARNING! This struct must match RedisModuleCommandKeySpec */ +/* WARNING! This struct must match RedictModuleCommandKeySpec */ typedef struct { /* Declarative data */ const char *notes; @@ -2187,7 +2187,7 @@ typedef struct jsonObject { #endif -/* WARNING! This struct must match RedisModuleCommandHistoryEntry */ +/* WARNING! This struct must match RedictModuleCommandHistoryEntry */ typedef struct { const char *since; const char *changes; @@ -2483,7 +2483,7 @@ moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name); void moduleTypeNameByID(char *name, uint64_t moduleid); const char *moduleTypeModuleName(moduleType *mt); const char *moduleNameFromCommand(struct redictCommand *cmd); -void moduleFreeContext(struct RedisModuleCtx *ctx); +void moduleFreeContext(struct RedictModuleCtx *ctx); void moduleCallCommandUnblockedHandler(client *c); int isModuleClientUnblocked(client *c); void unblockClientFromModule(client *c); diff --git a/src/tls.c b/src/tls.c index b7b626ab0..5b14db3ba 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1149,7 +1149,7 @@ int RedictRegisterConnectionTypeTLS(void) { #include "release.h" -int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { +int RedictModule_OnLoad(void *ctx, RedictModuleString **argv, int argc) { UNUSED(argv); UNUSED(argc); @@ -1159,16 +1159,16 @@ int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { return REDISMODULE_ERR; } - if (RedisModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) + if (RedictModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; /* Connection modules is available only bootup. */ - if ((RedisModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { + if ((RedictModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { serverLog(LL_NOTICE, "Connection type %s can be loaded only during bootup", CONN_TYPE_TLS); return REDISMODULE_ERR; } - RedisModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); + RedictModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); if(connTypeRegister(&CT_TLS) != C_OK) return REDISMODULE_ERR; @@ -1176,7 +1176,7 @@ int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { return REDISMODULE_OK; } -int RedisModule_OnUnload(void *arg) { +int RedictModule_OnUnload(void *arg) { UNUSED(arg); serverLog(LL_NOTICE, "Connection type %s can not be unloaded", CONN_TYPE_TLS); return REDISMODULE_ERR;