From aaec321213605e6315d85f2e617b4f33420b8df7 Mon Sep 17 00:00:00 2001 From: Ping Xie Date: Fri, 5 Apr 2024 16:59:55 -0700 Subject: [PATCH] Remove REDISMODULE_ prefixes and introduce compatibility header (#194) Fix #146 Removed REDISMODULE_ prefixes from the core source code to align with the new SERVERMODULE_ naming convention. Added a new 'redismodule.h' header file to ensure full backward compatibility with existing modules. This compatibility layer maps all legacy REDISMODULE_ prefixed identifiers to their new SERVERMODULE_ equivalents, allowing existing Redis modules to function without modification. --------- Signed-off-by: Ping Xie --- src/aof.c | 2 +- src/call_reply.c | 112 +- src/call_reply.h | 2 +- src/config.c | 6 +- src/db.c | 18 +- src/debug.c | 2 +- src/functions.h | 2 +- src/module.c | 5656 ++++++++++++++++++------------------ src/modules/Makefile | 16 +- src/modules/helloacl.c | 58 +- src/modules/helloblock.c | 42 +- src/modules/hellocluster.c | 38 +- src/modules/hellodict.c | 32 +- src/modules/hellohook.c | 24 +- src/modules/hellotimer.c | 24 +- src/modules/hellotype.c | 94 +- src/modules/helloworld.c | 220 +- src/networking.c | 12 +- src/rdb.c | 44 +- src/redismodule.h | 2408 +++++---------- src/replication.c | 48 +- src/server.c | 24 +- src/server.h | 98 +- src/tls.c | 24 +- src/valkeymodule.h | 1698 +++++++++++ 25 files changed, 5728 insertions(+), 4976 deletions(-) create mode 100644 src/valkeymodule.h diff --git a/src/aof.c b/src/aof.c index c775d5b612..ab24770b9a 100644 --- a/src/aof.c +++ b/src/aof.c @@ -2211,7 +2211,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) { * that is exported by a module and is not handled by Redis itself. * The function returns 0 on error, 1 on success. */ int rewriteModuleObject(rio *r, robj *key, robj *o, int dbid) { - RedisModuleIO io; + ValkeyModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitIOContext(io,mt,r,key,dbid); diff --git a/src/call_reply.c b/src/call_reply.c index ccd1b36d45..0afaf4469e 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -73,55 +73,55 @@ static void callReplySetSharedData(CallReply *rep, int type, const char *proto, static void callReplyNull(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, REPLY_FLAG_RESP3); } static void callReplyNullBulkString(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0); } static void callReplyNullArray(void *ctx, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_NULL, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_NULL, proto, proto_len, 0); } static void callReplyBulkString(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplyError(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_ERROR, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_ERROR, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplySimpleStr(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_STRING, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_STRING, proto, proto_len, 0); rep->len = len; rep->val.str = str; } static void callReplyLong(void *ctx, long long val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_INTEGER, proto, proto_len, 0); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_INTEGER, proto, proto_len, 0); rep->val.ll = val; } static void callReplyDouble(void *ctx, double val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_DOUBLE, proto, proto_len, REPLY_FLAG_RESP3); rep->val.d = val; } static void callReplyVerbatimString(void *ctx, const char *format, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3); rep->len = len; rep->val.verbatim_str.str = str; rep->val.verbatim_str.format = format; @@ -129,14 +129,14 @@ static void callReplyVerbatimString(void *ctx, const char *format, const char *s static void callReplyBigNumber(void *ctx, const char *str, size_t len, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_BIG_NUMBER, proto, proto_len, REPLY_FLAG_RESP3); rep->len = len; rep->val.str = str; } static void callReplyBool(void *ctx, int val, const char *proto, size_t proto_len) { CallReply *rep = ctx; - callReplySetSharedData(rep, REDISMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3); + callReplySetSharedData(rep, VALKEYMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3); rep->val.ll = val; } @@ -164,7 +164,7 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const /* Continue parsing the attribute reply */ rep->attribute->len = len; - rep->attribute->type = REDISMODULE_REPLY_ATTRIBUTE; + rep->attribute->type = VALKEYMODULE_REPLY_ATTRIBUTE; callReplyParseCollection(parser, rep->attribute, len, proto, 2); rep->attribute->flags |= REPLY_FLAG_PARSED | REPLY_FLAG_RESP3; rep->attribute->private_data = rep->private_data; @@ -180,39 +180,39 @@ static void callReplyAttribute(ReplyParser *parser, void *ctx, size_t len, const static void callReplyArray(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_ARRAY; + rep->type = VALKEYMODULE_REPLY_ARRAY; callReplyParseCollection(parser, rep, len, proto, 1); } static void callReplySet(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_SET; + rep->type = VALKEYMODULE_REPLY_SET; callReplyParseCollection(parser, rep, len, proto, 1); rep->flags |= REPLY_FLAG_RESP3; } static void callReplyMap(ReplyParser *parser, void *ctx, size_t len, const char *proto) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_MAP; + rep->type = VALKEYMODULE_REPLY_MAP; callReplyParseCollection(parser, rep, len, proto, 2); rep->flags |= REPLY_FLAG_RESP3; } static void callReplyParseError(void *ctx) { CallReply *rep = ctx; - rep->type = REDISMODULE_REPLY_UNKNOWN; + rep->type = VALKEYMODULE_REPLY_UNKNOWN; } /* Recursively free the current call reply and its sub-replies. */ static void freeCallReplyInternal(CallReply *rep) { - if (rep->type == REDISMODULE_REPLY_ARRAY || rep->type == REDISMODULE_REPLY_SET) { + if (rep->type == VALKEYMODULE_REPLY_ARRAY || rep->type == VALKEYMODULE_REPLY_SET) { for (size_t i = 0 ; i < rep->len ; ++i) { freeCallReplyInternal(rep->val.array + i); } zfree(rep->val.array); } - if (rep->type == REDISMODULE_REPLY_MAP || rep->type == REDISMODULE_REPLY_ATTRIBUTE) { + if (rep->type == VALKEYMODULE_REPLY_MAP || rep->type == VALKEYMODULE_REPLY_ATTRIBUTE) { for (size_t i = 0 ; i < rep->len ; ++i) { freeCallReplyInternal(rep->val.array + i * 2); freeCallReplyInternal(rep->val.array + i * 2 + 1); @@ -234,7 +234,7 @@ void freeCallReply(CallReply *rep) { return; } if (rep->flags & REPLY_FLAG_PARSED) { - if (rep->type == REDISMODULE_REPLY_PROMISE) { + if (rep->type == VALKEYMODULE_REPLY_PROMISE) { zfree(rep); return; } @@ -248,7 +248,7 @@ void freeCallReply(CallReply *rep) { CallReply *callReplyCreatePromise(void *private_data) { CallReply *res = zmalloc(sizeof(*res)); - res->type = REDISMODULE_REPLY_PROMISE; + res->type = VALKEYMODULE_REPLY_PROMISE; /* Mark the reply as parsed so there will be not attempt to parse * it when calling reply API such as freeCallReply. * Also mark the reply as root so freeCallReply will not ignore it. */ @@ -289,16 +289,16 @@ static void callReplyParse(CallReply *rep) { rep->flags |= REPLY_FLAG_PARSED; } -/* Return the call reply type (REDISMODULE_REPLY_...). */ +/* Return the call reply type (VALKEYMODULE_REPLY_...). */ int callReplyType(CallReply *rep) { - if (!rep) return REDISMODULE_REPLY_UNKNOWN; + if (!rep) return VALKEYMODULE_REPLY_UNKNOWN; callReplyParse(rep); return rep->type; } /* Return reply string as buffer and len. Applicable to: - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. @@ -308,56 +308,56 @@ int callReplyType(CallReply *rep) { */ const char *callReplyGetString(CallReply *rep, size_t *len) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_STRING && - rep->type != REDISMODULE_REPLY_ERROR) return NULL; + if (rep->type != VALKEYMODULE_REPLY_STRING && + rep->type != VALKEYMODULE_REPLY_ERROR) return NULL; if (len) *len = rep->len; return rep->val.str; } /* Return a long long reply value. Applicable to: - * - REDISMODULE_REPLY_INTEGER + * - VALKEYMODULE_REPLY_INTEGER */ long long callReplyGetLongLong(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_INTEGER) return LLONG_MIN; + if (rep->type != VALKEYMODULE_REPLY_INTEGER) return LLONG_MIN; return rep->val.ll; } /* Return a double reply value. Applicable to: - * - REDISMODULE_REPLY_DOUBLE + * - VALKEYMODULE_REPLY_DOUBLE */ double callReplyGetDouble(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_DOUBLE) return LLONG_MIN; + if (rep->type != VALKEYMODULE_REPLY_DOUBLE) return LLONG_MIN; return rep->val.d; } /* Return a reply Boolean value. Applicable to: - * - REDISMODULE_REPLY_BOOL + * - VALKEYMODULE_REPLY_BOOL */ int callReplyGetBool(CallReply *rep) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_BOOL) return INT_MIN; + if (rep->type != VALKEYMODULE_REPLY_BOOL) return INT_MIN; return rep->val.ll; } /* Return reply length. Applicable to: - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR - * - REDISMODULE_REPLY_ARRAY - * - REDISMODULE_REPLY_SET - * - REDISMODULE_REPLY_MAP - * - REDISMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_ATTRIBUTE */ size_t callReplyGetLen(CallReply *rep) { callReplyParse(rep); switch(rep->type) { - case REDISMODULE_REPLY_STRING: - case REDISMODULE_REPLY_ERROR: - case REDISMODULE_REPLY_ARRAY: - case REDISMODULE_REPLY_SET: - case REDISMODULE_REPLY_MAP: - case REDISMODULE_REPLY_ATTRIBUTE: + case VALKEYMODULE_REPLY_STRING: + case VALKEYMODULE_REPLY_ERROR: + case VALKEYMODULE_REPLY_ARRAY: + case VALKEYMODULE_REPLY_SET: + case VALKEYMODULE_REPLY_MAP: + case VALKEYMODULE_REPLY_ATTRIBUTE: return rep->len; default: return 0; @@ -370,26 +370,26 @@ static CallReply *callReplyGetCollectionElement(CallReply *rep, size_t idx, int } /* Return a reply array element at a given index. Applicable to: - * - REDISMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_ARRAY * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. */ CallReply *callReplyGetArrayElement(CallReply *rep, size_t idx) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_ARRAY) return NULL; + if (rep->type != VALKEYMODULE_REPLY_ARRAY) return NULL; return callReplyGetCollectionElement(rep, idx, 1); } /* Return a reply set element at a given index. Applicable to: - * - REDISMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_SET * * The return value is borrowed from CallReply, so it must not be freed * explicitly or used after CallReply itself is freed. */ CallReply *callReplyGetSetElement(CallReply *rep, size_t idx) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_SET) return NULL; + if (rep->type != VALKEYMODULE_REPLY_SET) return NULL; return callReplyGetCollectionElement(rep, idx, 1); } @@ -403,7 +403,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply } /* Retrieve a map reply key and value at a given index. Applicable to: - * - REDISMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_MAP * * The key and value are returned by reference through key and val, * which may also be NULL if not needed. @@ -415,7 +415,7 @@ static int callReplyGetMapElementInternal(CallReply *rep, size_t idx, CallReply * explicitly or used after CallReply itself is freed. */ int callReplyGetMapElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) { - return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP); + return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP); } /* Return reply attribute, or NULL if it does not exist. Applicable to all replies. @@ -428,7 +428,7 @@ CallReply *callReplyGetAttribute(CallReply *rep) { } /* Retrieve attribute reply key and value at a given index. Applicable to: - * - REDISMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_ATTRIBUTE * * The key and value are returned by reference through key and val, * which may also be NULL if not needed. @@ -440,11 +440,11 @@ CallReply *callReplyGetAttribute(CallReply *rep) { * explicitly or used after CallReply itself is freed. */ int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, CallReply **val) { - return callReplyGetMapElementInternal(rep, idx, key, val, REDISMODULE_REPLY_MAP); + return callReplyGetMapElementInternal(rep, idx, key, val, VALKEYMODULE_REPLY_MAP); } /* Return a big number reply value. Applicable to: - * - REDISMODULE_REPLY_BIG_NUMBER + * - VALKEYMODULE_REPLY_BIG_NUMBER * * The returned values are borrowed from CallReply, so they must not be freed * explicitly or used after CallReply itself is freed. @@ -457,13 +457,13 @@ int callReplyGetAttributeElement(CallReply *rep, size_t idx, CallReply **key, Ca */ const char *callReplyGetBigNumber(CallReply *rep, size_t *len) { callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_BIG_NUMBER) return NULL; + if (rep->type != VALKEYMODULE_REPLY_BIG_NUMBER) return NULL; *len = rep->len; return rep->val.str; } /* Return a verbatim string reply value. Applicable to: - * - REDISMODULE_REPLY_VERBATIM_STRING + * - VALKEYMODULE_REPLY_VERBATIM_STRING * * If format is non-NULL, the verbatim reply format is also returned by value. * @@ -478,7 +478,7 @@ const char *callReplyGetBigNumber(CallReply *rep, size_t *len) { */ const char *callReplyGetVerbatim(CallReply *rep, size_t *len, const char **format){ callReplyParse(rep); - if (rep->type != REDISMODULE_REPLY_VERBATIM_STRING) return NULL; + if (rep->type != VALKEYMODULE_REPLY_VERBATIM_STRING) return NULL; *len = rep->len; if (format) *format = rep->val.verbatim_str.format; return rep->val.verbatim_str.str; diff --git a/src/call_reply.h b/src/call_reply.h index 657f24735c..3ca1dd7c4f 100644 --- a/src/call_reply.h +++ b/src/call_reply.h @@ -33,7 +33,7 @@ #include "resp_parser.h" typedef struct CallReply CallReply; -typedef void (*RedisModuleOnUnblocked)(void *ctx, CallReply *reply, void *private_data); +typedef void (*ValkeyModuleOnUnblocked)(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/config.c b/src/config.c index c009589e15..eee7835924 100644 --- a/src/config.c +++ b/src/config.c @@ -934,8 +934,8 @@ void configSetCommand(client *c) { goto err; } - RedisModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; - moduleFireServerEvent(REDISMODULE_EVENT_CONFIG, REDISMODULE_SUBEVENT_CONFIG_CHANGE, &cc); + ValkeyModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names}; + moduleFireServerEvent(VALKEYMODULE_EVENT_CONFIG, VALKEYMODULE_SUBEVENT_CONFIG_CHANGE, &cc); addReply(c,shared.ok); goto end; @@ -1588,7 +1588,7 @@ void rewriteConfigLoadmoduleOption(struct rewriteConfigState *state) { dictIterator *di = dictGetIterator(modules); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *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 f58bde45df..886f27c0b9 100644 --- a/src/db.c +++ b/src/db.c @@ -524,7 +524,7 @@ long long emptyDbStructure(serverDb *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}; + ValkeyModuleFlushInfoV1 fi = {VALKEYMODULE_FLUSHINFO_VERSION,!async,dbnum}; long long removed = 0; if (dbnum < -1 || dbnum >= server.dbnum) { @@ -533,8 +533,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { } /* Fire the flushdb modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB, - REDISMODULE_SUBEVENT_FLUSHDB_START, + moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB, + VALKEYMODULE_SUBEVENT_FLUSHDB_START, &fi); /* Make sure the WATCHed keys are affected by the FLUSH* commands. @@ -554,8 +554,8 @@ long long emptyData(int dbnum, int flags, void(callback)(dict*)) { /* Also fire the end event. Note that this event will fire almost * immediately after the start event if the flush is asynchronous. */ - moduleFireServerEvent(REDISMODULE_EVENT_FLUSHDB, - REDISMODULE_SUBEVENT_FLUSHDB_END, + moduleFireServerEvent(VALKEYMODULE_EVENT_FLUSHDB, + VALKEYMODULE_SUBEVENT_FLUSHDB_END, &fi); return removed; @@ -865,7 +865,7 @@ int objectTypeCompare(robj *o, long long target) { return 1; } /* module type compare */ - long long mt = (long long)REDISMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id); + long long mt = (long long)VALKEYMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id); if (target != -mt) return 0; else @@ -951,7 +951,7 @@ long long getObjectTypeByName(char *name) { } moduleType *mt = moduleTypeLookupModuleByNameIgnoreCase(name); - if (mt != NULL) return -(REDISMODULE_TYPE_SIGN(mt->id)); + if (mt != NULL) return -(VALKEYMODULE_TYPE_SIGN(mt->id)); return LLONG_MAX; } @@ -1680,8 +1680,8 @@ void swapdbCommand(client *c) { addReplyError(c,"DB index is out of range"); return; } else { - RedisModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2}; - moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si); + ValkeyModuleSwapDbInfo si = {VALKEYMODULE_SWAPDBINFO_VERSION,id1,id2}; + moduleFireServerEvent(VALKEYMODULE_EVENT_SWAPDB,0,&si); server.dirty++; addReply(c,shared.ok); } diff --git a/src/debug.c b/src/debug.c index bdae441005..adce284c2b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -258,7 +258,7 @@ void xorObjectDigest(serverDb *db, robj *keyobj, unsigned char *digest, robj *o) } streamIteratorStop(&si); } else if (o->type == OBJ_MODULE) { - RedisModuleDigest md = {{0},{0},keyobj,db->id}; + ValkeyModuleDigest md = {{0},{0},keyobj,db->id}; moduleValue *mv = o->ptr; moduleType *mt = mv->type; moduleInitDigestContext(md); diff --git a/src/functions.h b/src/functions.h index bb0ea4cb24..5228560859 100644 --- a/src/functions.h +++ b/src/functions.h @@ -50,7 +50,7 @@ #include "server.h" #include "script.h" -#include "redismodule.h" +#include "valkeymodule.h" typedef struct functionLibInfo functionLibInfo; diff --git a/src/module.c b/src/module.c index eecb45fb48..3e48b32836 100644 --- a/src/module.c +++ b/src/module.c @@ -33,8 +33,8 @@ * The comments in this file are used to generate the API documentation on the * Redis website. * - * Each function starting with RM_ and preceded by a block comment is included - * in the API documentation. To hide an RM_ function, put a blank line between + * Each function starting with VM_ and preceded by a block comment is included + * in the API documentation. To hide a VM_ function, put a blank line between * the comment and the function definition or put the comment inside the * function body. * @@ -47,7 +47,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 ValkeyModule in * function names. For details, see the script src/modules/gendoc.rb. * -------------------------------------------------------------------------- */ @@ -60,6 +60,7 @@ #include "call_reply.h" #include "hdr_histogram.h" #include "crc16_slottable.h" +#include "valkeymodule.h" #include #include #include @@ -72,8 +73,8 @@ * pointers that have an API the module can call with them) * -------------------------------------------------------------------------- */ -struct RedisModuleInfoCtx { - struct RedisModule *module; +struct ValkeyModuleInfoCtx { + struct ValkeyModule *module; dict *requested_sections; sds info; /* info string we collected so far */ int sections; /* number of sections we collected so far */ @@ -85,13 +86,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 ValkeyModuleSharedAPI { void *func; - RedisModule *module; + ValkeyModule *module; }; -typedef struct RedisModuleSharedAPI RedisModuleSharedAPI; +typedef struct ValkeyModuleSharedAPI ValkeyModuleSharedAPI; -dict *modules; /* Hash table of modules. SDS -> RedisModule ptr.*/ +dict *modules; /* Hash table of modules. SDS -> ValkeyModule ptr.*/ /* Entries in the context->amqueue array, representing objects to free * when the callback returns. */ @@ -101,12 +102,12 @@ struct AutoMemEntry { }; /* AutoMemEntry type field values. */ -#define REDISMODULE_AM_KEY 0 -#define REDISMODULE_AM_STRING 1 -#define REDISMODULE_AM_REPLY 2 -#define REDISMODULE_AM_FREED 3 /* Explicitly freed by user already. */ -#define REDISMODULE_AM_DICT 4 -#define REDISMODULE_AM_INFO 5 +#define VALKEYMODULE_AM_KEY 0 +#define VALKEYMODULE_AM_STRING 1 +#define VALKEYMODULE_AM_REPLY 2 +#define VALKEYMODULE_AM_FREED 3 /* Explicitly freed by user already. */ +#define VALKEYMODULE_AM_DICT 4 +#define VALKEYMODULE_AM_INFO 5 /* The pool allocator block. Redis Modules can allocate memory via this special * allocator that will automatically release it all once the callback returns. @@ -121,15 +122,15 @@ struct AutoMemEntry { * Allocations are always rounded to the size of the void pointer in order * to always return aligned memory chunks. */ -#define REDISMODULE_POOL_ALLOC_MIN_SIZE (1024*8) -#define REDISMODULE_POOL_ALLOC_ALIGN (sizeof(void*)) +#define VALKEYMODULE_POOL_ALLOC_MIN_SIZE (1024*8) +#define VALKEYMODULE_POOL_ALLOC_ALIGN (sizeof(void*)) -typedef struct RedisModulePoolAllocBlock { +typedef struct ValkeyModulePoolAllocBlock { uint32_t size; uint32_t used; - struct RedisModulePoolAllocBlock *next; + struct ValkeyModulePoolAllocBlock *next; char memory[]; -} RedisModulePoolAllocBlock; +} ValkeyModulePoolAllocBlock; /* 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 @@ -139,56 +140,56 @@ 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 ValkeyModuleBlockedClient; +struct ValkeyModuleUser; -struct RedisModuleCtx { +struct ValkeyModuleCtx { void *getapifuncptr; /* NOTE: Must be the first field. */ - struct RedisModule *module; /* Module reference. */ + struct ValkeyModule *module; /* Module reference. */ client *client; /* Client calling a command. */ - struct RedisModuleBlockedClient *blocked_client; /* Blocked client for + struct ValkeyModuleBlockedClient *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. */ int amqueue_used; /* Number of used slots in amqueue. */ - int flags; /* REDISMODULE_CTX_... flags. */ - void **postponed_arrays; /* To set with RM_ReplySetArrayLength(). */ + int flags; /* VALKEYMODULE_CTX_... flags. */ + void **postponed_arrays; /* To set with VM_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 + ValkeyModuleString *blocked_ready_key; /* Key ready when the reply callback gets called for clients blocked on keys. */ - /* Used if there is the REDISMODULE_CTX_KEYS_POS_REQUEST or - * REDISMODULE_CTX_CHANNEL_POS_REQUEST flag set. */ + /* Used if there is the VALKEYMODULE_CTX_KEYS_POS_REQUEST or + * VALKEYMODULE_CTX_CHANNEL_POS_REQUEST flag set. */ getKeysResult *keys_result; - struct RedisModulePoolAllocBlock *pa_head; + struct ValkeyModulePoolAllocBlock *pa_head; long long next_yield_time; - const struct RedisModuleUser *user; /* RedisModuleUser commands executed via - RM_Call should be executed as, if set */ + const struct ValkeyModuleUser *user; /* ValkeyModuleUser commands executed via + VM_Call should be executed as, if set */ }; -typedef struct RedisModuleCtx RedisModuleCtx; - -#define REDISMODULE_CTX_NONE (0) -#define REDISMODULE_CTX_AUTO_MEMORY (1<<0) -#define REDISMODULE_CTX_KEYS_POS_REQUEST (1<<1) -#define REDISMODULE_CTX_BLOCKED_REPLY (1<<2) -#define REDISMODULE_CTX_BLOCKED_TIMEOUT (1<<3) -#define REDISMODULE_CTX_THREAD_SAFE (1<<4) -#define REDISMODULE_CTX_BLOCKED_DISCONNECTED (1<<5) -#define REDISMODULE_CTX_TEMP_CLIENT (1<<6) /* Return client object to the pool +typedef struct ValkeyModuleCtx ValkeyModuleCtx; + +#define VALKEYMODULE_CTX_NONE (0) +#define VALKEYMODULE_CTX_AUTO_MEMORY (1<<0) +#define VALKEYMODULE_CTX_KEYS_POS_REQUEST (1<<1) +#define VALKEYMODULE_CTX_BLOCKED_REPLY (1<<2) +#define VALKEYMODULE_CTX_BLOCKED_TIMEOUT (1<<3) +#define VALKEYMODULE_CTX_THREAD_SAFE (1<<4) +#define VALKEYMODULE_CTX_BLOCKED_DISCONNECTED (1<<5) +#define VALKEYMODULE_CTX_TEMP_CLIENT (1<<6) /* Return client object to the pool when the context is destroyed */ -#define REDISMODULE_CTX_NEW_CLIENT (1<<7) /* Free client object when the +#define VALKEYMODULE_CTX_NEW_CLIENT (1<<7) /* Free client object when the context is destroyed */ -#define REDISMODULE_CTX_CHANNELS_POS_REQUEST (1<<8) -#define REDISMODULE_CTX_COMMAND (1<<9) /* Context created to serve a command from call() or AOF (which calls cmd->proc directly) */ +#define VALKEYMODULE_CTX_CHANNELS_POS_REQUEST (1<<8) +#define VALKEYMODULE_CTX_COMMAND (1<<9) /* Context created to serve a command from call() or AOF (which calls cmd->proc directly) */ -/* This represents a Redis key opened with RM_OpenKey(). */ -struct RedisModuleKey { - RedisModuleCtx *ctx; +/* This represents a Redis key opened with VM_OpenKey(). */ +struct ValkeyModuleKey { + ValkeyModuleCtx *ctx; serverDb *db; robj *key; /* Key name object. */ robj *value; /* Value object, or NULL if the key was not found. */ @@ -203,7 +204,7 @@ struct RedisModuleKey { } list; struct { /* Zset iterator, use only if value->type == OBJ_ZSET */ - uint32_t type; /* REDISMODULE_ZSET_RANGE_* */ + uint32_t type; /* VALKEYMODULE_ZSET_RANGE_* */ zrangespec rs; /* Score range. */ zlexrangespec lrs; /* Lex range. */ uint32_t start; /* Start pos for positional ranges. */ @@ -221,69 +222,69 @@ struct RedisModuleKey { } u; }; -/* RedisModuleKey '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 -#define REDISMODULE_ZSET_RANGE_POS 3 +/* ValkeyModuleKey 'ztype' values. */ +#define VALKEYMODULE_ZSET_RANGE_NONE 0 /* This must always be 0. */ +#define VALKEYMODULE_ZSET_RANGE_LEX 1 +#define VALKEYMODULE_ZSET_RANGE_SCORE 2 +#define VALKEYMODULE_ZSET_RANGE_POS 3 /* 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 ValkeyModuleBlockedClient; +typedef int (*ValkeyModuleCmdFunc) (ValkeyModuleCtx *ctx, void **argv, int argc); +typedef int (*ValkeyModuleAuthCallback)(ValkeyModuleCtx *ctx, void *username, void *password, ValkeyModuleString **err); +typedef void (*ValkeyModuleDisconnectFunc) (ValkeyModuleCtx *ctx, struct ValkeyModuleBlockedClient *bc); /* This struct holds the information about a command registered by a module.*/ -struct RedisModuleCommand { - struct RedisModule *module; - RedisModuleCmdFunc func; +struct ValkeyModuleCommand { + struct ValkeyModule *module; + ValkeyModuleCmdFunc func; struct serverCommand *rediscmd; }; -typedef struct RedisModuleCommand RedisModuleCommand; +typedef struct ValkeyModuleCommand ValkeyModuleCommand; -#define REDISMODULE_REPLYFLAG_NONE 0 -#define REDISMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */ -#define REDISMODULE_REPLYFLAG_NESTED (1<<1) /* Nested reply object. No proto +#define VALKEYMODULE_REPLYFLAG_NONE 0 +#define VALKEYMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */ +#define VALKEYMODULE_REPLYFLAG_NESTED (1<<1) /* Nested reply object. No proto or struct free. */ -/* Reply of RM_Call() function. The function is filled in a lazy +/* Reply of VM_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 ValkeyModuleCallReply; /* Structure to hold the module auth callback & the Module implementing it. */ -typedef struct RedisModuleAuthCtx { - struct RedisModule *module; - RedisModuleAuthCallback auth_cb; -} RedisModuleAuthCtx; +typedef struct ValkeyModuleAuthCtx { + struct ValkeyModule *module; + ValkeyModuleAuthCallback auth_cb; +} ValkeyModuleAuthCtx; /* Structure representing a blocked client. We get a pointer to such * an object when blocking from modules. */ -typedef struct RedisModuleBlockedClient { +typedef struct ValkeyModuleBlockedClient { 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 + ValkeyModule *module; /* Module blocking the client. */ + ValkeyModuleCmdFunc reply_callback; /* Reply callback on normal completion.*/ + ValkeyModuleAuthCallback 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.*/ + ValkeyModuleCmdFunc timeout_callback; /* Reply callback on timeout. */ + ValkeyModuleDisconnectFunc disconnect_callback; /* Called on disconnection.*/ + void (*free_privdata)(ValkeyModuleCtx*,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. */ + ValkeyModule_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 in thread safe contexts. */ int dbid; /* Database number selected by the original client. */ - int blocked_on_keys; /* If blocked via RM_BlockClientOnKeys(). */ + int blocked_on_keys; /* If blocked via VM_BlockClientOnKeys(). */ int unblocked; /* Already on the moduleUnblocked list. */ 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; +} ValkeyModuleBlockedClient; /* 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 @@ -308,33 +309,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 (*ValkeyModuleNotificationFunc) (ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key); /* Function pointer type for post jobs */ -typedef void (*RedisModulePostNotificationJobFunc) (RedisModuleCtx *ctx, void *pd); +typedef void (*ValkeyModulePostNotificationJobFunc) (ValkeyModuleCtx *ctx, void *pd); /* Keyspace notification subscriber information. - * See RM_SubscribeToKeyspaceEvents() for more information. */ -typedef struct RedisModuleKeyspaceSubscriber { + * See VM_SubscribeToKeyspaceEvents() for more information. */ +typedef struct ValkeyModuleKeyspaceSubscriber { /* The module subscribed to the event */ - RedisModule *module; + ValkeyModule *module; /* Notification callback in the module*/ - RedisModuleNotificationFunc notify_callback; + ValkeyModuleNotificationFunc 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; +} ValkeyModuleKeyspaceSubscriber; -typedef struct RedisModulePostExecUnitJob { +typedef struct ValkeyModulePostExecUnitJob { /* The module subscribed to the event */ - RedisModule *module; - RedisModulePostNotificationJobFunc callback; + ValkeyModule *module; + ValkeyModulePostNotificationJobFunc callback; void *pd; void (*free_pd)(void*); int dbid; -} RedisModulePostExecUnitJob; +} ValkeyModulePostExecUnitJob; /* The module keyspace notification subscribers list */ static list *moduleKeyspaceSubscribers; @@ -343,168 +344,168 @@ static list *moduleKeyspaceSubscribers; static list *modulePostExecUnitJobs; /* Data structures related to the exported dictionary data structure. */ -typedef struct RedisModuleDict { +typedef struct ValkeyModuleDict { rax *rax; /* The radix tree. */ -} RedisModuleDict; +} ValkeyModuleDict; -typedef struct RedisModuleDictIter { - RedisModuleDict *dict; +typedef struct ValkeyModuleDictIter { + ValkeyModuleDict *dict; raxIterator ri; -} RedisModuleDictIter; +} ValkeyModuleDictIter; -typedef struct RedisModuleCommandFilterCtx { - RedisModuleString **argv; +typedef struct ValkeyModuleCommandFilterCtx { + ValkeyModuleString **argv; int argv_len; int argc; client *c; -} RedisModuleCommandFilterCtx; +} ValkeyModuleCommandFilterCtx; -typedef void (*RedisModuleCommandFilterFunc) (RedisModuleCommandFilterCtx *filter); +typedef void (*ValkeyModuleCommandFilterFunc) (ValkeyModuleCommandFilterCtx *filter); -typedef struct RedisModuleCommandFilter { +typedef struct ValkeyModuleCommandFilter { /* The module that registered the filter */ - RedisModule *module; + ValkeyModule *module; /* Filter callback function */ - RedisModuleCommandFilterFunc callback; - /* REDISMODULE_CMDFILTER_* flags */ + ValkeyModuleCommandFilterFunc callback; + /* VALKEYMODULE_CMDFILTER_* flags */ int flags; -} RedisModuleCommandFilter; +} ValkeyModuleCommandFilter; /* Registered filters */ static list *moduleCommandFilters; -typedef void (*RedisModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*ValkeyModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); -static struct RedisModuleForkInfo { - RedisModuleForkDoneHandler done_handler; +static struct ValkeyModuleForkInfo { + ValkeyModuleForkDoneHandler done_handler; void* done_handler_user_data; } moduleForkInfo = {0}; -typedef struct RedisModuleServerInfoData { +typedef struct ValkeyModuleServerInfoData { rax *rax; /* parsed info data. */ -} RedisModuleServerInfoData; +} ValkeyModuleServerInfoData; /* Flags for moduleCreateArgvFromUserFormat(). */ -#define REDISMODULE_ARGV_REPLICATE (1<<0) -#define REDISMODULE_ARGV_NO_AOF (1<<1) -#define REDISMODULE_ARGV_NO_REPLICAS (1<<2) -#define REDISMODULE_ARGV_RESP_3 (1<<3) -#define REDISMODULE_ARGV_RESP_AUTO (1<<4) -#define REDISMODULE_ARGV_RUN_AS_USER (1<<5) -#define REDISMODULE_ARGV_SCRIPT_MODE (1<<6) -#define REDISMODULE_ARGV_NO_WRITES (1<<7) -#define REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS (1<<8) -#define REDISMODULE_ARGV_RESPECT_DENY_OOM (1<<9) -#define REDISMODULE_ARGV_DRY_RUN (1<<10) -#define REDISMODULE_ARGV_ALLOW_BLOCK (1<<11) +#define VALKEYMODULE_ARGV_REPLICATE (1<<0) +#define VALKEYMODULE_ARGV_NO_AOF (1<<1) +#define VALKEYMODULE_ARGV_NO_REPLICAS (1<<2) +#define VALKEYMODULE_ARGV_RESP_3 (1<<3) +#define VALKEYMODULE_ARGV_RESP_AUTO (1<<4) +#define VALKEYMODULE_ARGV_RUN_AS_USER (1<<5) +#define VALKEYMODULE_ARGV_SCRIPT_MODE (1<<6) +#define VALKEYMODULE_ARGV_NO_WRITES (1<<7) +#define VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS (1<<8) +#define VALKEYMODULE_ARGV_RESPECT_DENY_OOM (1<<9) +#define VALKEYMODULE_ARGV_DRY_RUN (1<<10) +#define VALKEYMODULE_ARGV_ALLOW_BLOCK (1<<11) /* Determine whether Redis should signalModifiedKey implicitly. * In case 'ctx' has no 'module' member (and therefore no module->options), * we assume default behavior, that is, Redis signals. - * (see RM_GetThreadSafeContext) */ + * (see VM_GetThreadSafeContext) */ #define SHOULD_SIGNAL_MODIFIED_KEYS(ctx) \ - ((ctx)->module? !((ctx)->module->options & REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) : 1) + ((ctx)->module? !((ctx)->module->options & VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) : 1) /* Server events hooks data structures and defines: this modules API * allow modules to subscribe to certain events in Redis, such as * 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 ValkeyModuleEventListener { + ValkeyModule *module; + ValkeyModuleEvent event; + ValkeyModuleEventCallback callback; +} ValkeyModuleEventListener; -list *RedisModule_EventListeners; /* Global list of all the active events. */ +list *ValkeyModule_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 +/* This is the object returned by VM_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 ValkeyModuleUser { user *user; /* Reference to the real redis user */ int free_user; /* Indicates that user should also be freed when this object is freed */ -} RedisModuleUser; +} ValkeyModuleUser; /* This is a structure used to export some meta-information such as dbid to the module. */ -typedef struct RedisModuleKeyOptCtx { +typedef struct ValkeyModuleKeyOptCtx { struct serverObject *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; +} ValkeyModuleKeyOptCtx; /* Data structures related to redis module configurations */ -/* The function signatures for module config get callbacks. These are identical to the ones exposed in redismodule.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); -/* The function signatures for module config set callbacks. These are identical to the ones exposed in redismodule.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); -/* Apply signature, identical to redismodule.h */ -typedef int (*RedisModuleConfigApplyFunc)(RedisModuleCtx *ctx, void *privdata, RedisModuleString **err); +/* The function signatures for module config get callbacks. These are identical to the ones exposed in valkeymodule.h. */ +typedef ValkeyModuleString * (*ValkeyModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*ValkeyModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetEnumFunc)(const char *name, void *privdata); +/* The function signatures for module config set callbacks. These are identical to the ones exposed in valkeymodule.h. */ +typedef int (*ValkeyModuleConfigSetStringFunc)(const char *name, ValkeyModuleString *val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +/* Apply signature, identical to valkeymodule.h */ +typedef int (*ValkeyModuleConfigApplyFunc)(ValkeyModuleCtx *ctx, void *privdata, ValkeyModuleString **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; + ValkeyModuleConfigGetStringFunc get_string; + ValkeyModuleConfigGetNumericFunc get_numeric; + ValkeyModuleConfigGetBoolFunc get_bool; + ValkeyModuleConfigGetEnumFunc 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; + ValkeyModuleConfigSetStringFunc set_string; + ValkeyModuleConfigSetNumericFunc set_numeric; + ValkeyModuleConfigSetBoolFunc set_bool; + ValkeyModuleConfigSetEnumFunc set_enum; } set_fn; - RedisModuleConfigApplyFunc apply_fn; - RedisModule *module; + ValkeyModuleConfigApplyFunc apply_fn; + ValkeyModule *module; }; -typedef struct RedisModuleAsyncRMCallPromise{ +typedef struct ValkeyModuleAsyncRMCallPromise{ size_t ref_count; void *private_data; - RedisModule *module; - RedisModuleOnUnblocked on_unblocked; + ValkeyModule *module; + ValkeyModuleOnUnblocked on_unblocked; client *c; - RedisModuleCtx *ctx; -} RedisModuleAsyncRMCallPromise; + ValkeyModuleCtx *ctx; +} ValkeyModuleAsyncRMCallPromise; /* -------------------------------------------------------------------------- * Prototypes * -------------------------------------------------------------------------- */ -void RM_FreeCallReply(RedisModuleCallReply *reply); -void RM_CloseKey(RedisModuleKey *key); -void autoMemoryCollect(RedisModuleCtx *ctx); +void VM_FreeCallReply(ValkeyModuleCallReply *reply); +void VM_CloseKey(ValkeyModuleKey *key); +void autoMemoryCollect(ValkeyModuleCtx *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); - -/* Helpers for RM_SetCommandInfo. */ -static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info); +void VM_ZsetRangeStop(ValkeyModuleKey *kp); +static void zsetKeyReset(ValkeyModuleKey *key); +static void moduleInitKeyTypeSpecific(ValkeyModuleKey *key); +void VM_FreeDict(ValkeyModuleCtx *ctx, ValkeyModuleDict *d); +void VM_FreeServerInfo(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data); + +/* Helpers for VM_SetCommandInfo. */ +static int moduleValidateCommandInfo(const ValkeyModuleCommandInfo *info); static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api); -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version); -static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error); +static int moduleValidateCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version); +static struct serverCommandArg *moduleCopyCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version); +static serverCommandArgType moduleConvertArgType(ValkeyModuleCommandArgType type, int *error); static int moduleConvertArgFlags(int flags); -void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_flags); +void moduleCreateContext(ValkeyModuleCtx *out_ctx, ValkeyModule *module, int ctx_flags); /* Common helper functions. */ int moduleVerifyResourceName(const char *name); @@ -521,10 +522,10 @@ int moduleVerifyResourceName(const char *name); * and in general is taken into account as memory allocated by Redis. * You should avoid using malloc(). * This function panics if unable to allocate enough memory. */ -void *RM_Alloc(size_t bytes) { +void *VM_Alloc(size_t bytes) { /* Use 'zmalloc_usable()' instead of 'zmalloc()' to allow the compiler * to recognize the additional memory size, which means that modules can - * use the memory reported by 'RM_MallocUsableSize()' safely. In theory this + * use the memory reported by 'VM_MallocUsableSize()' safely. In theory this * isn't really needed since this API can't be inlined (not even for embedded * modules like TLS (we use function pointers for module APIs), and the API doesn't * have the malloc_size attribute, but it's hard to predict how smart future compilers @@ -532,9 +533,9 @@ void *RM_Alloc(size_t bytes) { return zmalloc_usable(bytes,NULL); } -/* Similar to RM_Alloc, but returns NULL in case of allocation failure, instead +/* Similar to VM_Alloc, but returns NULL in case of allocation failure, instead * of panicking. */ -void *RM_TryAlloc(size_t bytes) { +void *VM_TryAlloc(size_t bytes) { return ztrymalloc_usable(bytes,NULL); } @@ -542,36 +543,36 @@ void *RM_TryAlloc(size_t bytes) { * Redis INFO memory, used for keys eviction according to maxmemory settings * and in general is taken into account as memory allocated by Redis. * You should avoid using calloc() directly. */ -void *RM_Calloc(size_t nmemb, size_t size) { +void *VM_Calloc(size_t nmemb, size_t size) { return zcalloc_usable(nmemb*size,NULL); } -/* Similar to RM_Calloc, but returns NULL in case of allocation failure, instead +/* Similar to VM_Calloc, but returns NULL in case of allocation failure, instead * of panicking. */ -void *RM_TryCalloc(size_t nmemb, size_t size) { +void *VM_TryCalloc(size_t nmemb, size_t size) { return ztrycalloc_usable(nmemb*size,NULL); } -/* Use like realloc() for memory obtained with RedisModule_Alloc(). */ -void* RM_Realloc(void *ptr, size_t bytes) { +/* Use like realloc() for memory obtained with ValkeyModule_Alloc(). */ +void* VM_Realloc(void *ptr, size_t bytes) { return zrealloc_usable(ptr,bytes,NULL); } -/* Similar to RM_Realloc, but returns NULL in case of allocation failure, +/* Similar to VM_Realloc, but returns NULL in case of allocation failure, * instead of panicking. */ -void *RM_TryRealloc(void *ptr, size_t bytes) { +void *VM_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. */ -void RM_Free(void *ptr) { +/* Use like free() for memory obtained by ValkeyModule_Alloc() and + * ValkeyModule_Realloc(). However you should never try to free with + * ValkeyModule_Free() memory allocated with malloc() inside your module. */ +void VM_Free(void *ptr) { zfree(ptr); } -/* Like strdup() but returns memory allocated with RedisModule_Alloc(). */ -char *RM_Strdup(const char *str) { +/* Like strdup() but returns memory allocated with ValkeyModule_Alloc(). */ +char *VM_Strdup(const char *str) { return zstrdup(str); } @@ -580,8 +581,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(ValkeyModuleCtx *ctx) { + ValkeyModulePoolAllocBlock *head = ctx->pa_head, *next; while(head != NULL) { next = head->next; @@ -603,14 +604,14 @@ 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 *VM_PoolAlloc(ValkeyModuleCtx *ctx, size_t bytes) { if (bytes == 0) return NULL; - RedisModulePoolAllocBlock *b = ctx->pa_head; + ValkeyModulePoolAllocBlock *b = ctx->pa_head; size_t left = b ? b->size - b->used : 0; /* Fix alignment. */ if (left >= bytes) { - size_t alignment = REDISMODULE_POOL_ALLOC_ALIGN; + size_t alignment = VALKEYMODULE_POOL_ALLOC_ALIGN; while (bytes < alignment && alignment/2 >= bytes) alignment /= 2; if (b->used % alignment) b->used += alignment - (b->used % alignment); @@ -619,7 +620,7 @@ void *RM_PoolAlloc(RedisModuleCtx *ctx, size_t bytes) { /* Create a new block if needed. */ if (left < bytes) { - size_t blocksize = REDISMODULE_POOL_ALLOC_MIN_SIZE; + size_t blocksize = VALKEYMODULE_POOL_ALLOC_MIN_SIZE; if (blocksize < bytes) blocksize = bytes; b = zmalloc(sizeof(*b) + blocksize); b->size = blocksize; @@ -652,12 +653,12 @@ client *moduleAllocTempClient(void) { return c; } -static void freeRedisModuleAsyncRMCallPromise(RedisModuleAsyncRMCallPromise *promise) { +static void freeRedisModuleAsyncRMCallPromise(ValkeyModuleAsyncRMCallPromise *promise) { if (--promise->ref_count > 0) { return; } /* When the promise is finally freed it can not have a client attached to it. - * Either releasing the client or RM_CallReplyPromiseAbort would have removed it. */ + * Either releasing the client or VM_CallReplyPromiseAbort would have removed it. */ serverAssert(!promise->c); zfree(promise); } @@ -677,7 +678,7 @@ 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; + ValkeyModuleAsyncRMCallPromise *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); c->bstate.async_rm_call_handle = NULL; @@ -689,44 +690,44 @@ void moduleReleaseTempClient(client *c) { * opened for writing where the `.value` member is set to NULL because the * key was found to be non existing. * - * On success REDISMODULE_OK is returned and the key is populated with + * On success VALKEYMODULE_OK is returned and the key is populated with * the value of the specified type. The function fails and returns - * REDISMODULE_ERR if: + * VALKEYMODULE_ERR if: * * 1. The key is not open for writing. * 2. The key is not empty. * 3. The specified type is unknown. */ -int moduleCreateEmptyKey(RedisModuleKey *key, int type) { +int moduleCreateEmptyKey(ValkeyModuleKey *key, int type) { robj *obj; /* The key must be open for writing and non existing to proceed. */ - if (!(key->mode & REDISMODULE_WRITE) || key->value) - return REDISMODULE_ERR; + if (!(key->mode & VALKEYMODULE_WRITE) || key->value) + return VALKEYMODULE_ERR; switch(type) { - case REDISMODULE_KEYTYPE_LIST: + case VALKEYMODULE_KEYTYPE_LIST: obj = createListListpackObject(); break; - case REDISMODULE_KEYTYPE_ZSET: + case VALKEYMODULE_KEYTYPE_ZSET: obj = createZsetListpackObject(); break; - case REDISMODULE_KEYTYPE_HASH: + case VALKEYMODULE_KEYTYPE_HASH: obj = createHashObject(); break; - case REDISMODULE_KEYTYPE_STREAM: + case VALKEYMODULE_KEYTYPE_STREAM: obj = createStreamObject(); break; - default: return REDISMODULE_ERR; + default: return VALKEYMODULE_ERR; } dbAdd(key->db,key->key,obj); key->value = obj; moduleInitKeyTypeSpecific(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Frees key->iter and sets it to NULL. */ -static void moduleFreeKeyIterator(RedisModuleKey *key) { +static void moduleFreeKeyIterator(ValkeyModuleKey *key) { serverAssert(key->iter != NULL); switch (key->value->type) { case OBJ_LIST: listTypeReleaseIterator(key->iter); break; @@ -742,7 +743,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; + ValkeyModuleKey *key = (ValkeyModuleKey*)data; serverAssert(key->value->type == OBJ_LIST); if (key->iter) moduleFreeKeyIterator(key); } @@ -757,8 +758,8 @@ 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) { - if (!(key->mode & REDISMODULE_WRITE) || key->value == NULL) return 0; +int moduleDelKeyIfEmpty(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL) return 0; int isempty; robj *o = key->value; @@ -784,24 +785,24 @@ 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 - * pointers in redismodule.h). In this way the dynamic linker does not + * Note that all the exported APIs are called VM_ in the core + * and ValkeyModule_ in the module side (defined as function + * pointers in valkeymodule.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. * -------------------------------------------------------------------------- */ -int RM_GetApi(const char *funcname, void **targetPtrPtr) { +int VM_GetApi(const char *funcname, void **targetPtrPtr) { /* Lookup the requested module API and store the function pointer into the - * target pointer. The function returns REDISMODULE_ERR if there is no such - * named API, otherwise REDISMODULE_OK. + * target pointer. The function returns VALKEYMODULE_ERR if there is no such + * named API, otherwise VALKEYMODULE_OK. * * This function is not meant to be used by modules developer, it is only - * used implicitly by including redismodule.h. */ + * used implicitly by including valkeymodule.h. */ dictEntry *he = dictFind(server.moduleapi, funcname); - if (!he) return REDISMODULE_ERR; + if (!he) return VALKEYMODULE_ERR; *targetPtrPtr = dictGetVal(he); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void modulePostExecutionUnitOperations(void) { @@ -818,9 +819,9 @@ void modulePostExecutionUnitOperations(void) { } /* Free the context after the user function was called. */ -void moduleFreeContext(RedisModuleCtx *ctx) { +void moduleFreeContext(ValkeyModuleCtx *ctx) { /* See comment in moduleCreateContext */ - if (!(ctx->flags & (REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_COMMAND))) { + if (!(ctx->flags & (VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_COMMAND))) { exitExecutionUnit(); postExecutionUnitOperations(); } @@ -831,8 +832,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() " + "ValkeyModule_ReplyWith*(VALKEYMODULE_POSTPONED_LEN) " + "not matched by the same number of ValkeyModule_SetReply*Len() " "calls.", ctx->module->name); } @@ -840,13 +841,13 @@ void moduleFreeContext(RedisModuleCtx *ctx) { * If this context created a new client (e.g detached context), we free it. * If the client is assigned manually, e.g ctx->client = someClientInstance, * none of these flags will be set and we do not attempt to free it. */ - if (ctx->flags & REDISMODULE_CTX_TEMP_CLIENT) + if (ctx->flags & VALKEYMODULE_CTX_TEMP_CLIENT) moduleReleaseTempClient(ctx->client); - else if (ctx->flags & REDISMODULE_CTX_NEW_CLIENT) + else if (ctx->flags & VALKEYMODULE_CTX_NEW_CLIENT) freeClient(ctx->client); } -static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { +static CallReply *moduleParseReply(client *c, ValkeyModuleCtx *ctx) { /* Convert the result of the Redis command into a module reply. */ sds proto = sdsnewlen(c->buf,c->bufpos); c->bufpos = 0; @@ -862,15 +863,15 @@ static CallReply *moduleParseReply(client *c, RedisModuleCtx *ctx) { } void moduleCallCommandUnblockedHandler(client *c) { - RedisModuleCtx ctx; - RedisModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; + ValkeyModuleCtx ctx; + ValkeyModuleAsyncRMCallPromise *promise = c->bstate.async_rm_call_handle; serverAssert(promise); - RedisModule *module = promise->module; + ValkeyModule *module = promise->module; if (!promise->on_unblocked) { moduleReleaseTempClient(c); return; /* module did not set any unblock callback. */ } - moduleCreateContext(&ctx, module, REDISMODULE_CTX_TEMP_CLIENT); + moduleCreateContext(&ctx, module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, c->db->id); CallReply *reply = moduleParseReply(c, NULL); @@ -884,18 +885,18 @@ void moduleCallCommandUnblockedHandler(client *c) { /* Create a module ctx and keep track of the nesting level. * - * Note: When creating ctx for threads (RM_GetThreadSafeContext and - * RM_GetDetachedThreadSafeContext) we do not bump up the nesting level + * Note: When creating ctx for threads (VM_GetThreadSafeContext and + * VM_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)); - out_ctx->getapifuncptr = (void*)(unsigned long)&RM_GetApi; +void moduleCreateContext(ValkeyModuleCtx *out_ctx, ValkeyModule *module, int ctx_flags) { + memset(out_ctx, 0 ,sizeof(ValkeyModuleCtx)); + out_ctx->getapifuncptr = (void*)(unsigned long)&VM_GetApi; out_ctx->module = module; out_ctx->flags = ctx_flags; - if (ctx_flags & REDISMODULE_CTX_TEMP_CLIENT) + if (ctx_flags & VALKEYMODULE_CTX_TEMP_CLIENT) out_ctx->client = moduleAllocTempClient(); - else if (ctx_flags & REDISMODULE_CTX_NEW_CLIENT) + else if (ctx_flags & VALKEYMODULE_CTX_NEW_CLIENT) out_ctx->client = createClient(NULL); /* Calculate the initial yield time for long blocked contexts. @@ -917,17 +918,17 @@ void moduleCreateContext(RedisModuleCtx *out_ctx, RedisModule *module, int ctx_f * call() and in the latter we don't care about execution_nesting * 2. If we are running in a thread (execution_nesting will be dealt with * when locking/unlocking the GIL) */ - if (!(ctx_flags & (REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_COMMAND))) { + if (!(ctx_flags & (VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_COMMAND))) { enterExecutionUnit(1, 0); } } /* 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; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_COMMAND); +void ValkeyModuleCommandDispatcher(client *c) { + ValkeyModuleCommand *cp = c->cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_COMMAND); ctx.client = c; cp->func(&ctx,(void**)c->argv,c->argc); @@ -958,18 +959,18 @@ 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 ValkeyModule_IsKeysPositionRequest(ctx). */ int moduleGetCommandKeysViaAPI(struct serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST); + ValkeyModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_KEYS_POS_REQUEST); /* Initialize getKeysResult */ getKeysPrepareResult(result, MAX_KEYS_BUFFER); ctx.keys_result = result; cp->func(&ctx,(void**)argv,argc); - /* We currently always use the array allocated by RM_KeyAtPos() and don't try + /* We currently always use the array allocated by VM_KeyAtPos() and don't try * to optimize for the pre-allocated buffer. */ moduleFreeContext(&ctx); @@ -980,16 +981,16 @@ int moduleGetCommandKeysViaAPI(struct serverCommand *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 serverCommand *cmd, robj **argv, int argc, getKeysResult *result) { - RedisModuleCommand *cp = cmd->module_cmd; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST); + ValkeyModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cp->module, VALKEYMODULE_CTX_CHANNELS_POS_REQUEST); /* Initialize getKeysResult */ getKeysPrepareResult(result, MAX_KEYS_BUFFER); ctx.keys_result = result; cp->func(&ctx,(void**)argv,argc); - /* We currently always use the array allocated by RM_RM_ChannelAtPosWithFlags() and don't try + /* We currently always use the array allocated by VM_RM_ChannelAtPosWithFlags() and don't try * to optimize for the pre-allocated buffer. */ moduleFreeContext(&ctx); return result->numkeys; @@ -1006,32 +1007,32 @@ int moduleGetCommandChannelsViaAPI(struct serverCommand *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) { - return (ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) != 0; +int VM_IsKeysPositionRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_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 + * ValkeyModule_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_*. + * The supported flags are the ones used by VM_SetCommandInfo, see VALKEYMODULE_CMD_KEY_*. * * * 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 (ValkeyModule_IsKeysPositionRequest(ctx)) { + * ValkeyModule_KeyAtPosWithFlags(ctx, 2, VALKEYMODULE_CMD_KEY_RO | VALKEYMODULE_CMD_KEY_ACCESS); + * ValkeyModule_KeyAtPosWithFlags(ctx, 1, VALKEYMODULE_CMD_KEY_RW | VALKEYMODULE_CMD_KEY_UPDATE | VALKEYMODULE_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) { - if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return; +void VM_KeyAtPosWithFlags(ValkeyModuleCtx *ctx, int pos, int flags) { + if (!(ctx->flags & VALKEYMODULE_CTX_KEYS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; getKeysResult *res = ctx->keys_result; @@ -1047,50 +1048,50 @@ void RM_KeyAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { res->numkeys++; } -/* This API existed before RM_KeyAtPosWithFlags was added, now deprecated and +/* This API existed before VM_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 VM_KeyAtPos(ValkeyModuleCtx *ctx, int pos) { /* Default flags require full access */ int flags = moduleConvertKeySpecsFlags(CMD_KEY_FULL_ACCESS, 0); - RM_KeyAtPosWithFlags(ctx, pos, flags); + VM_KeyAtPosWithFlags(ctx, pos, flags); } /* 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) { - return (ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) != 0; +int VM_IsChannelsPositionRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_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 ValkeyModule_IsChannelsPositionRequest() API and uses this * function in order to report the channels. * * The supported flags are: - * * REDISMODULE_CMD_CHANNEL_SUBSCRIBE: This command will subscribe to the channel. - * * REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE: This command will unsubscribe from this channel. - * * REDISMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel. - * * REDISMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any + * * VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE: This command will subscribe to the channel. + * * VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE: This command will unsubscribe from this channel. + * * VALKEYMODULE_CMD_CHANNEL_PUBLISH: This command will publish to this channel. + * * VALKEYMODULE_CMD_CHANNEL_PATTERN: Instead of acting on a specific channel, will act on any * channel specified by the pattern. This is the same access * used by the PSUBSCRIBE and PUNSUBSCRIBE commands available * in Redis. Not intended to be used with PUBLISH permissions. * * 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 (ValkeyModule_IsChannelsPositionRequest(ctx)) { + * ValkeyModule_ChannelAtPosWithFlags(ctx, 1, VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE | VALKEYMODULE_CMD_CHANNEL_PATTERN); + * ValkeyModule_ChannelAtPosWithFlags(ctx, 1, VALKEYMODULE_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 + * publish permissions. This is preferred over using VM_ACLCheckChannelPermissions, since * it allows the ACLs to be checked before the command is executed. */ -void RM_ChannelAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { - if (!(ctx->flags & REDISMODULE_CTX_CHANNELS_POS_REQUEST) || !ctx->keys_result) return; +void VM_ChannelAtPosWithFlags(ValkeyModuleCtx *ctx, int pos, int flags) { + if (!(ctx->flags & VALKEYMODULE_CTX_CHANNELS_POS_REQUEST) || !ctx->keys_result) return; if (pos <= 0) return; getKeysResult *res = ctx->keys_result; @@ -1102,10 +1103,10 @@ void RM_ChannelAtPosWithFlags(RedisModuleCtx *ctx, int pos, int flags) { } int new_flags = 0; - if (flags & REDISMODULE_CMD_CHANNEL_SUBSCRIBE) new_flags |= CMD_CHANNEL_SUBSCRIBE; - if (flags & REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE) new_flags |= CMD_CHANNEL_UNSUBSCRIBE; - if (flags & REDISMODULE_CMD_CHANNEL_PUBLISH) new_flags |= CMD_CHANNEL_PUBLISH; - if (flags & REDISMODULE_CMD_CHANNEL_PATTERN) new_flags |= CMD_CHANNEL_PATTERN; + if (flags & VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE) new_flags |= CMD_CHANNEL_SUBSCRIBE; + if (flags & VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE) new_flags |= CMD_CHANNEL_UNSUBSCRIBE; + if (flags & VALKEYMODULE_CMD_CHANNEL_PUBLISH) new_flags |= CMD_CHANNEL_PUBLISH; + if (flags & VALKEYMODULE_CMD_CHANNEL_PATTERN) new_flags |= CMD_CHANNEL_PATTERN; res->keys[res->numkeys].pos = pos; res->keys[res->numkeys].flags = new_flags; @@ -1132,7 +1133,7 @@ int isCommandNameValid(const char *name) { return 1; } -/* Helper for RM_CreateCommand(). Turns a string representing command +/* Helper for VM_CreateCommand(). Turns a string representing command * flags into the command flags used by the Redis core. * * It returns the set of flags, or -1 if unknown flags are found. */ @@ -1169,29 +1170,29 @@ 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); +ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds declared_name, sds fullname, ValkeyModuleCmdFunc 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 ValkeyModule calling * convention. * - * The function returns REDISMODULE_ERR in these cases: - * - If creation of module command is called outside the RedisModule_OnLoad. + * The function returns VALKEYMODULE_ERR in these cases: + * - If creation of module command is called outside the ValkeyModule_OnLoad. * - The specified command is already busy. * - The command name contains some chars that are not allowed. * - A set of invalid flags were passed. * - * Otherwise REDISMODULE_OK is returned and the new command is registered. + * Otherwise VALKEYMODULE_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 ValkeyModule_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(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc); * - * And is supposed to always return REDISMODULE_OK. + * And is supposed to always return VALKEYMODULE_OK. * * The set of flags 'strflags' specify the behavior of the command, and should * be passed as a C string composed of space separated words, like for @@ -1243,7 +1244,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec * * **"blocking"**: The command has the potential to block the client. * * **"allow-busy"**: Permit the command while the server is blocked either by * a script or by a slow module command, see - * RM_Yield. + * VM_Yield. * * **"getchannels-api"**: The command implements the interface to return * the arguments that are channels. * @@ -1265,32 +1266,32 @@ 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) { + * ValkeyModule_SetCommandInfo to set key specs using a more advanced scheme and use + * ValkeyModule_SetCommandACLCategories to set Redis ACL categories of the commands. */ +int VM_CreateCommand(ValkeyModuleCtx *ctx, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!ctx->module->onload) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; - if (flags == -1) return REDISMODULE_ERR; + if (flags == -1) return VALKEYMODULE_ERR; if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is valid. */ if (!isCommandNameValid(name)) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is busy. */ if (lookupCommandByCString(name) != NULL) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; sds declared_name = sdsnew(name); - RedisModuleCommand *cp = moduleCreateCommandProxy(ctx->module, declared_name, sdsdup(declared_name), cmdfunc, flags, firstkey, lastkey, keystep); + ValkeyModuleCommand *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); serverAssert(dictAdd(server.orig_commands, sdsdup(declared_name), cp->rediscmd) == DICT_OK); cp->rediscmd->id = ACLGetCommandID(declared_name); /* ID used for ACL. */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* A proxy that help create a module command / subcommand. @@ -1300,9 +1301,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) { +ValkeyModuleCommand *moduleCreateCommandProxy(struct ValkeyModule *module, sds declared_name, sds fullname, ValkeyModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) { struct serverCommand *rediscmd; - RedisModuleCommand *cp; + ValkeyModuleCommand *cp; /* Create a command "proxy", which is a structure that is referenced * in the command table, so that the generic command that works as @@ -1315,7 +1316,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 = ValkeyModuleCommandDispatcher; cp->rediscmd->flags = flags | CMD_MODULE; cp->rediscmd->module_cmd = cp; if (firstkey != 0) { @@ -1351,101 +1352,101 @@ 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) { +ValkeyModuleCommand *VM_GetCommand(ValkeyModuleCtx *ctx, const char *name) { struct serverCommand *cmd = lookupCommandByCString(name); if (!cmd || !(cmd->flags & CMD_MODULE)) return NULL; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *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 ValkeyModule_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) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateCommand(ctx,"module.config",NULL,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * RedisModuleCommand *parent = RedisModule_GetCommand(ctx,,"module.config"); + * ValkeyModuleCommand *parent = ValkeyModule_GetCommand(ctx,,"module.config"); * - * if (RedisModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == REDISMODULE_ERR) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateSubcommand(parent,"set",cmd_config_set,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * if (RedisModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == REDISMODULE_ERR) - * return REDISMODULE_ERR; + * if (ValkeyModule_CreateSubcommand(parent,"get",cmd_config_get,"",0,0,0) == VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR in case of the following errors: + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR in case of the following errors: * * * 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 (ValkeyModuleCmdFunc) (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 ValkeyModule_OnLoad. */ -int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { +int VM_CreateSubcommand(ValkeyModuleCommand *parent, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) { if (!parent->module->onload) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; int64_t flags = strflags ? commandFlagsFromString((char*)strflags) : 0; - if (flags == -1) return REDISMODULE_ERR; + if (flags == -1) return VALKEYMODULE_ERR; if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; struct serverCommand *parent_cmd = parent->rediscmd; if (parent_cmd->parent) - return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */ + return VALKEYMODULE_ERR; /* We don't allow more than one level of subcommands */ - RedisModuleCommand *parent_cp = parent_cmd->module_cmd; + ValkeyModuleCommand *parent_cp = parent_cmd->module_cmd; if (parent_cp->func) - return REDISMODULE_ERR; /* A parent command should be a pure container of subcommands */ + return VALKEYMODULE_ERR; /* A parent command should be a pure container of subcommands */ /* Check if the command name is valid. */ if (!isCommandNameValid(name)) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Check if the command name is busy within the parent command. */ sds declared_name = sdsnew(name); if (parent_cmd->subcommands_dict && lookupSubcommand(parent_cmd, declared_name) != NULL) { sdsfree(declared_name); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } sds fullname = catSubCommandFullname(parent_cmd->fullname, name); - RedisModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); + ValkeyModuleCommand *cp = moduleCreateCommandProxy(parent->module, declared_name, fullname, cmdfunc, flags, firstkey, lastkey, keystep); cp->rediscmd->arity = -2; commandAddSubcommand(parent_cmd, cp->rediscmd, name); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 ValkeyModuleCommandHistoryEntry * +moduleCmdHistoryEntryAt(const ValkeyModuleCommandInfoVersion *version, + ValkeyModuleCommandHistoryEntry *entries, int index) { off_t offset = index * version->sizeof_historyentry; - return (RedisModuleCommandHistoryEntry *)((char *)(entries) + offset); + return (ValkeyModuleCommandHistoryEntry *)((char *)(entries) + offset); } -static RedisModuleCommandKeySpec * -moduleCmdKeySpecAt(const RedisModuleCommandInfoVersion *version, - RedisModuleCommandKeySpec *keyspecs, int index) { +static ValkeyModuleCommandKeySpec * +moduleCmdKeySpecAt(const ValkeyModuleCommandInfoVersion *version, + ValkeyModuleCommandKeySpec *keyspecs, int index) { off_t offset = index * version->sizeof_keyspec; - return (RedisModuleCommandKeySpec *)((char *)(keyspecs) + offset); + return (ValkeyModuleCommandKeySpec *)((char *)(keyspecs) + offset); } -static RedisModuleCommandArg * -moduleCmdArgAt(const RedisModuleCommandInfoVersion *version, - const RedisModuleCommandArg *args, int index) { +static ValkeyModuleCommandArg * +moduleCmdArgAt(const ValkeyModuleCommandInfoVersion *version, + const ValkeyModuleCommandArg *args, int index) { off_t offset = index * version->sizeof_arg; - return (RedisModuleCommandArg *)((char *)(args) + offset); + return (ValkeyModuleCommandArg *)((char *)(args) + offset); } /* Recursively populate the args structure (setting num_args to the number of @@ -1463,42 +1464,42 @@ int populateArgsStructure(struct serverCommandArg *args) { return count; } -/* RedisModule_AddACLCategory can be used to add new ACL command categories. Category names +/* ValkeyModule_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 ValkeyModule_OnLoad function. Once a category has been added, it can not be removed. + * Any module can register a command to any added categories using ValkeyModule_SetCommandACLCategories. * * Returns: - * - REDISMODULE_OK on successfully adding the new ACL category. - * - REDISMODULE_ERR on failure. + * - VALKEYMODULE_OK on successfully adding the new ACL category. + * - VALKEYMODULE_ERR on failure. * * On error the errno is set to: * - EINVAL if the name contains invalid characters. * - 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 VM_AddACLCategory(ValkeyModuleCtx *ctx, const char *name) { if (!ctx->module->onload) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (moduleVerifyResourceName(name) == REDISMODULE_ERR) { + if (moduleVerifyResourceName(name) == VALKEYMODULE_ERR) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLGetCommandCategoryFlagByName(name)) { errno = EBUSY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLAddCommandCategory(name, 0)) { ctx->module->num_acl_categories_added++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { errno = ENOMEM; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } @@ -1516,7 +1517,7 @@ int matchAclCategoryFlag(char *flag, int64_t *acl_categories_flags) { return 0; /* Unrecognized */ } -/* Helper for RM_SetCommandACLCategories(). Turns a string representing acl category +/* Helper for VM_SetCommandACLCategories(). Turns a string representing acl category * flags into the acl category flags used by Redis ACL which allows users to access * the module commands by acl categories. * @@ -1537,26 +1538,26 @@ int64_t categoryFlagsFromString(char *aclflags) { return acl_categories_flags; } -/* RedisModule_SetCommandACLCategories can be used to set ACL categories to module +/* ValkeyModule_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'. * * Example, the acl flags 'write slow' marks the command as part of the write and * slow ACL categories. * - * On success REDISMODULE_OK is returned. On error REDISMODULE_ERR is returned. + * On success VALKEYMODULE_OK is returned. On error VALKEYMODULE_ERR is returned. * - * This function can only be called during the RedisModule_OnLoad function. If called + * This function can only be called during the ValkeyModule_OnLoad function. If called * outside of this function, an error is returned. */ -int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags) { - if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR; +int VM_SetCommandACLCategories(ValkeyModuleCommand *command, const char *aclflags) { + if (!command || !command->module || !command->module->onload) return VALKEYMODULE_ERR; int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0; - if (categories_flags == -1) return REDISMODULE_ERR; + if (categories_flags == -1) return VALKEYMODULE_ERR; struct serverCommand *rcmd = command->rediscmd; rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */ command->module->num_commands_with_acl_categories++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set additional command information. @@ -1565,26 +1566,26 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * ACL and is used to filter commands with the wrong number of arguments before * the call reaches the module code. * - * This function can be called after creating a command using RM_CreateCommand - * and fetching the command pointer using RM_GetCommand. The information can + * This function can be called after creating a command using VM_CreateCommand + * and fetching the command pointer using VM_GetCommand. The information can * only be set once for each command and has the following structure: * - * typedef struct RedisModuleCommandInfo { - * const RedisModuleCommandInfoVersion *version; + * typedef struct ValkeyModuleCommandInfo { + * const ValkeyModuleCommandInfoVersion *version; * const char *summary; * const char *complexity; * const char *since; - * RedisModuleCommandHistoryEntry *history; + * ValkeyModuleCommandHistoryEntry *history; * const char *tips; * int arity; - * RedisModuleCommandKeySpec *key_specs; - * RedisModuleCommandArg *args; - * } RedisModuleCommandInfo; + * ValkeyModuleCommandKeySpec *key_specs; + * ValkeyModuleCommandArg *args; + * } ValkeyModuleCommandInfo; * * All fields except `version` are optional. Explanation of the fields: * * - `version`: This field enables compatibility with different Redis versions. - * Always set this field to REDISMODULE_COMMAND_INFO_VERSION. + * Always set this field to VALKEYMODULE_COMMAND_INFO_VERSION. * * - `summary`: A short description of the command (optional). * @@ -1593,7 +1594,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 ValkeyModuleCommandHistoryEntry (optional), which is * a struct with the following fields: * * const char *since; @@ -1614,9 +1615,9 @@ 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 ValkeyModuleCommandKeySpec, 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 + * positions of key arguments better than the old VM_CreateCommand arguments * `firstkey`, `lastkey`, `keystep` and is needed if those three are not * enough to describe the key positions. There are two steps to retrieve key * positions: *begin search* (BS) in which index should find the first key and @@ -1624,21 +1625,21 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * will which arguments are keys. Additionally, there are key specific flags. * * Key-specs cause the triplet (firstkey, lastkey, keystep) given in - * RM_CreateCommand to be recomputed, but it is still useful to provide - * these three parameters in RM_CreateCommand, to better support old Redis - * versions where RM_SetCommandInfo is not available. + * VM_CreateCommand to be recomputed, but it is still useful to provide + * these three parameters in VM_CreateCommand, to better support old Redis + * versions where VM_SetCommandInfo is not available. * * Note that key-specs don't fully replace the "getkeys-api" (see - * RM_CreateCommand, RM_IsKeysPositionRequest and RM_KeyAtPosWithFlags) so + * VM_CreateCommand, VM_IsKeysPositionRequest and VM_KeyAtPosWithFlags) so * it may be a good idea to supply both key-specs and implement the * getkeys-api. * * A key-spec has the following structure: * - * typedef struct RedisModuleCommandKeySpec { + * typedef struct ValkeyModuleCommandKeySpec { * const char *notes; * uint64_t flags; - * RedisModuleKeySpecBeginSearchType begin_search_type; + * ValkeyModuleKeySpecBeginSearchType begin_search_type; * union { * struct { * int pos; @@ -1648,7 +1649,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int startfrom; * } keyword; * } bs; - * RedisModuleKeySpecFindKeysType find_keys_type; + * ValkeyModuleKeySpecFindKeysType find_keys_type; * union { * struct { * int lastkey; @@ -1661,9 +1662,9 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * int keystep; * } keynum; * } fk; - * } RedisModuleCommandKeySpec; + * } ValkeyModuleCommandKeySpec; * - * Explanation of the fields of RedisModuleCommandKeySpec: + * Explanation of the fields of ValkeyModuleCommandKeySpec: * * * `notes`: Optional notes or clarifications about this key spec. * @@ -1672,34 +1673,34 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * `begin_search_type`: This describes how the first key is discovered. * There are two ways to determine the first key: * - * * `REDISMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the + * * `VALKEYMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the * key args start. - * * `REDISMODULE_KSPEC_BS_INDEX`: Key args start at a constant index. - * * `REDISMODULE_KSPEC_BS_KEYWORD`: Key args start just after a + * * `VALKEYMODULE_KSPEC_BS_INDEX`: Key args start at a constant index. + * * `VALKEYMODULE_KSPEC_BS_KEYWORD`: Key args start just after a * specific keyword. * * * `bs`: This is a union in which the `index` or `keyword` branch is used * depending on the value of the `begin_search_type` field. * * * `bs.index.pos`: The index from which we start the search for keys. - * (`REDISMODULE_KSPEC_BS_INDEX` only.) + * (`VALKEYMODULE_KSPEC_BS_INDEX` only.) * * * `bs.keyword.keyword`: The keyword (string) that indicates the - * beginning of key arguments. (`REDISMODULE_KSPEC_BS_KEYWORD` only.) + * beginning of key arguments. (`VALKEYMODULE_KSPEC_BS_KEYWORD` only.) * * * `bs.keyword.startfrom`: An index in argv from which to start * searching. Can be negative, which means start search from the end, * in reverse. Example: -2 means to start in reverse from the - * penultimate argument. (`REDISMODULE_KSPEC_BS_KEYWORD` only.) + * penultimate argument. (`VALKEYMODULE_KSPEC_BS_KEYWORD` only.) * * * `find_keys_type`: After the "begin search", this describes which * arguments are keys. The strategies are: * - * * `REDISMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the + * * `VALKEYMODULE_KSPEC_BS_UNKNOWN`: There is no way to tell where the * key args are located. - * * `REDISMODULE_KSPEC_FK_RANGE`: Keys end at a specific index (or + * * `VALKEYMODULE_KSPEC_FK_RANGE`: Keys end at a specific index (or * relative to the last argument). - * * `REDISMODULE_KSPEC_FK_KEYNUM`: There's an argument that contains + * * `VALKEYMODULE_KSPEC_FK_KEYNUM`: There's an argument that contains * the number of key args somewhere before the keys themselves. * * `find_keys_type` and `fk` can be omitted if this keyspec describes @@ -1708,7 +1709,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * * `fk`: This is a union in which the `range` or `keynum` branch is used * depending on the value of the `find_keys_type` field. * - * * `fk.range` (for `REDISMODULE_KSPEC_FK_RANGE`): A struct with the + * * `fk.range` (for `VALKEYMODULE_KSPEC_FK_RANGE`): A struct with the * following fields: * * * `lastkey`: Index of the last key relative to the result of the @@ -1723,7 +1724,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * by a factor. 0 and 1 mean no limit. 2 means 1/2 of the * remaining args, 3 means 1/3, and so on. * - * * `fk.keynum` (for `REDISMODULE_KSPEC_FK_KEYNUM`): A struct with the + * * `fk.keynum` (for `VALKEYMODULE_KSPEC_FK_KEYNUM`): A struct with the * following fields: * * * `keynumidx`: Index of the argument containing the number of @@ -1744,16 +1745,16 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * that's not distinctly deletion, overwrite or read-only would be marked as * RW. * - * * `REDISMODULE_CMD_KEY_RO`: Read-Only. Reads the value of the key, but + * * `VALKEYMODULE_CMD_KEY_RO`: Read-Only. Reads the value of the key, but * doesn't necessarily return it. * - * * `REDISMODULE_CMD_KEY_RW`: Read-Write. Modifies the data stored in the + * * `VALKEYMODULE_CMD_KEY_RW`: Read-Write. Modifies the data stored in the * value of the key or its metadata. * - * * `REDISMODULE_CMD_KEY_OW`: Overwrite. Overwrites the data stored in the + * * `VALKEYMODULE_CMD_KEY_OW`: Overwrite. Overwrites the data stored in the * value of the key. * - * * `REDISMODULE_CMD_KEY_RM`: Deletes the key. + * * `VALKEYMODULE_CMD_KEY_RM`: Deletes the key. * * The next four refer to *user data inside the value of the key*, not the * metadata like LRU, type, cardinality. It refers to the logical operation @@ -1763,107 +1764,107 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags * combined with one of the write operations INSERT, DELETE or UPDATE. Any * write that's not an INSERT or a DELETE would be UPDATE. * - * * `REDISMODULE_CMD_KEY_ACCESS`: Returns, copies or uses the user data + * * `VALKEYMODULE_CMD_KEY_ACCESS`: Returns, copies or uses the user data * from the value of the key. * - * * `REDISMODULE_CMD_KEY_UPDATE`: Updates data to the value, new value may + * * `VALKEYMODULE_CMD_KEY_UPDATE`: Updates data to the value, new value may * depend on the old value. * - * * `REDISMODULE_CMD_KEY_INSERT`: Adds data to the value with no chance of + * * `VALKEYMODULE_CMD_KEY_INSERT`: Adds data to the value with no chance of * modification or deletion of existing data. * - * * `REDISMODULE_CMD_KEY_DELETE`: Explicitly deletes some content from the + * * `VALKEYMODULE_CMD_KEY_DELETE`: Explicitly deletes some content from the * value of the key. * * Other flags: * - * * `REDISMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but + * * `VALKEYMODULE_CMD_KEY_NOT_KEY`: The key is not actually a key, but * should be routed in cluster mode as if it was a key. * - * * `REDISMODULE_CMD_KEY_INCOMPLETE`: The keyspec might not point out all + * * `VALKEYMODULE_CMD_KEY_INCOMPLETE`: The keyspec might not point out all * the keys it should cover. * - * * `REDISMODULE_CMD_KEY_VARIABLE_FLAGS`: Some keys might have different + * * `VALKEYMODULE_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 ValkeyModuleCommandArg, terminated by an element memset + * to zero. ValkeyModuleCommandArg is a structure with at the fields described * below. * - * typedef struct RedisModuleCommandArg { + * typedef struct ValkeyModuleCommandArg { * const char *name; - * RedisModuleCommandArgType type; + * ValkeyModuleCommandArgType type; * int key_spec_index; * const char *token; * const char *summary; * const char *since; * int flags; - * struct RedisModuleCommandArg *subargs; - * } RedisModuleCommandArg; + * struct ValkeyModuleCommandArg *subargs; + * } ValkeyModuleCommandArg; * * Explanation of the fields: * * * `name`: Name of the argument. * * * `type`: The type of the argument. See below for details. The types - * `REDISMODULE_ARG_TYPE_ONEOF` and `REDISMODULE_ARG_TYPE_BLOCK` require + * `VALKEYMODULE_ARG_TYPE_ONEOF` and `VALKEYMODULE_ARG_TYPE_BLOCK` require * an argument to have sub-arguments, i.e. `subargs`. * - * * `key_spec_index`: If the `type` is `REDISMODULE_ARG_TYPE_KEY` you must + * * `key_spec_index`: If the `type` is `VALKEYMODULE_ARG_TYPE_KEY` you must * provide the index of the key-spec associated with this argument. See * `key_specs` above. If the argument is not a key, you may specify -1. * * * `token`: The token preceding the argument (optional). Example: the * argument `seconds` in `SET` has a token `EX`. If the argument consists * of only a token (for example `NX` in `SET`) the type should be - * `REDISMODULE_ARG_TYPE_PURE_TOKEN` and `value` should be NULL. + * `VALKEYMODULE_ARG_TYPE_PURE_TOKEN` and `value` should be NULL. * * * `summary`: A short description of the argument (optional). * * * `since`: The first version which included this argument (optional). * - * * `flags`: A bitwise or of the macros `REDISMODULE_CMD_ARG_*`. See below. + * * `flags`: A bitwise or of the macros `VALKEYMODULE_CMD_ARG_*`. See below. * * * `value`: The display-value of the argument. This string is what should * 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 `ValkeyModuleCommandArgType`: * - * * `REDISMODULE_ARG_TYPE_STRING`: String argument. - * * `REDISMODULE_ARG_TYPE_INTEGER`: Integer argument. - * * `REDISMODULE_ARG_TYPE_DOUBLE`: Double-precision float argument. - * * `REDISMODULE_ARG_TYPE_KEY`: String argument representing a keyname. - * * `REDISMODULE_ARG_TYPE_PATTERN`: String, but regex pattern. - * * `REDISMODULE_ARG_TYPE_UNIX_TIME`: Integer, but Unix timestamp. - * * `REDISMODULE_ARG_TYPE_PURE_TOKEN`: Argument doesn't have a placeholder. + * * `VALKEYMODULE_ARG_TYPE_STRING`: String argument. + * * `VALKEYMODULE_ARG_TYPE_INTEGER`: Integer argument. + * * `VALKEYMODULE_ARG_TYPE_DOUBLE`: Double-precision float argument. + * * `VALKEYMODULE_ARG_TYPE_KEY`: String argument representing a keyname. + * * `VALKEYMODULE_ARG_TYPE_PATTERN`: String, but regex pattern. + * * `VALKEYMODULE_ARG_TYPE_UNIX_TIME`: Integer, but Unix timestamp. + * * `VALKEYMODULE_ARG_TYPE_PURE_TOKEN`: Argument doesn't have a placeholder. * It's just a token without a value. Example: the `KEEPTTL` option of the * `SET` command. - * * `REDISMODULE_ARG_TYPE_ONEOF`: Used when the user can choose only one of + * * `VALKEYMODULE_ARG_TYPE_ONEOF`: Used when the user can choose only one of * a few sub-arguments. Requires `subargs`. Example: the `NX` and `XX` * options of `SET`. - * * `REDISMODULE_ARG_TYPE_BLOCK`: Used when one wants to group together + * * `VALKEYMODULE_ARG_TYPE_BLOCK`: Used when one wants to group together * several sub-arguments, usually to apply something on all of them, like * making the entire group "optional". Requires `subargs`. Example: the * `LIMIT offset count` parameters in `ZRANGE`. * * Explanation of the command argument flags: * - * * `REDISMODULE_CMD_ARG_OPTIONAL`: The argument is optional (like GET in + * * `VALKEYMODULE_CMD_ARG_OPTIONAL`: The argument is optional (like GET in * the SET command). - * * `REDISMODULE_CMD_ARG_MULTIPLE`: The argument may repeat itself (like + * * `VALKEYMODULE_CMD_ARG_MULTIPLE`: The argument may repeat itself (like * key in DEL). - * * `REDISMODULE_CMD_ARG_MULTIPLE_TOKEN`: The argument may repeat itself, + * * `VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN`: The argument may repeat itself, * and so does its token (like `GET pattern` in SORT). * - * On success REDISMODULE_OK is returned. On error REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned. On error VALKEYMODULE_ERR is returned * 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 VM_SetCommandInfo(ValkeyModuleCommand *command, const ValkeyModuleCommandInfo *info) { if (!moduleValidateCommandInfo(info)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } struct serverCommand *cmd = command->rediscmd; @@ -1878,14 +1879,14 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo cmd->key_specs[0].begin_search_type == KSPEC_BS_INDEX && cmd->key_specs[0].find_keys_type == KSPEC_FK_RANGE))) { errno = EEXIST; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (info->summary) cmd->summary = zstrdup(info->summary); if (info->complexity) cmd->complexity = zstrdup(info->complexity); if (info->since) cmd->since = zstrdup(info->since); - const RedisModuleCommandInfoVersion *version = info->version; + const ValkeyModuleCommandInfoVersion *version = info->version; if (info->history) { size_t count = 0; while (moduleCmdHistoryEntryAt(version, info->history, count)->since) @@ -1893,7 +1894,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 = + ValkeyModuleCommandHistoryEntry *entry = moduleCmdHistoryEntryAt(version, info->history, j); cmd->history[j].since = zstrdup(entry->since); cmd->history[j].changes = zstrdup(entry->changes); @@ -1928,22 +1929,22 @@ 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 ValkeyModuleCommandKeySpec array. */ cmd->key_specs_num = count; for (size_t j = 0; j < count; j++) { - RedisModuleCommandKeySpec *spec = + ValkeyModuleCommandKeySpec *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); switch (spec->begin_search_type) { - case REDISMODULE_KSPEC_BS_UNKNOWN: + case VALKEYMODULE_KSPEC_BS_UNKNOWN: cmd->key_specs[j].begin_search_type = KSPEC_BS_UNKNOWN; break; - case REDISMODULE_KSPEC_BS_INDEX: + case VALKEYMODULE_KSPEC_BS_INDEX: cmd->key_specs[j].begin_search_type = KSPEC_BS_INDEX; cmd->key_specs[j].bs.index.pos = spec->bs.index.pos; break; - case REDISMODULE_KSPEC_BS_KEYWORD: + case VALKEYMODULE_KSPEC_BS_KEYWORD: cmd->key_specs[j].begin_search_type = KSPEC_BS_KEYWORD; cmd->key_specs[j].bs.keyword.keyword = zstrdup(spec->bs.keyword.keyword); cmd->key_specs[j].bs.keyword.startfrom = spec->bs.keyword.startfrom; @@ -1954,23 +1955,23 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo } switch (spec->find_keys_type) { - case REDISMODULE_KSPEC_FK_OMITTED: + case VALKEYMODULE_KSPEC_FK_OMITTED: /* Omitted field is shorthand to say that it's a single key. */ cmd->key_specs[j].find_keys_type = KSPEC_FK_RANGE; cmd->key_specs[j].fk.range.lastkey = 0; cmd->key_specs[j].fk.range.keystep = 1; cmd->key_specs[j].fk.range.limit = 0; break; - case REDISMODULE_KSPEC_FK_UNKNOWN: + case VALKEYMODULE_KSPEC_FK_UNKNOWN: cmd->key_specs[j].find_keys_type = KSPEC_FK_UNKNOWN; break; - case REDISMODULE_KSPEC_FK_RANGE: + case VALKEYMODULE_KSPEC_FK_RANGE: cmd->key_specs[j].find_keys_type = KSPEC_FK_RANGE; cmd->key_specs[j].fk.range.lastkey = spec->fk.range.lastkey; cmd->key_specs[j].fk.range.keystep = spec->fk.range.keystep; cmd->key_specs[j].fk.range.limit = spec->fk.range.limit; break; - case REDISMODULE_KSPEC_FK_KEYNUM: + case VALKEYMODULE_KSPEC_FK_KEYNUM: cmd->key_specs[j].find_keys_type = KSPEC_FK_KEYNUM; cmd->key_specs[j].fk.keynum.keynumidx = spec->fk.keynum.keynumidx; cmd->key_specs[j].fk.keynum.firstkey = spec->fk.keynum.firstkey; @@ -1996,7 +1997,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo /* Fields added in future versions to be added here, under conditions like * `if (info->version >= 2) { access version 2 fields here }` */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Returns 1 if v is a power of two, 0 otherwise. */ @@ -2005,8 +2006,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 ValkeyModuleCommandInfo *info) { + const ValkeyModuleCommandInfoVersion *version = info->version; if (!version) { serverLog(LL_WARNING, "Invalid command info: version missing"); return 0; @@ -2034,7 +2035,7 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { moduleCmdKeySpecAt(version, info->key_specs, j)->begin_search_type; j++) { - RedisModuleCommandKeySpec *spec = + ValkeyModuleCommandKeySpec *spec = moduleCmdKeySpecAt(version, info->key_specs, j); if (j >= INT_MAX) { serverLog(LL_WARNING, "Invalid command info: Too many key specs"); @@ -2044,11 +2045,11 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { /* Flags. Exactly one flag in a group is set if and only if the * masked bits is a power of two. */ uint64_t key_flags = - REDISMODULE_CMD_KEY_RO | REDISMODULE_CMD_KEY_RW | - REDISMODULE_CMD_KEY_OW | REDISMODULE_CMD_KEY_RM; + VALKEYMODULE_CMD_KEY_RO | VALKEYMODULE_CMD_KEY_RW | + VALKEYMODULE_CMD_KEY_OW | VALKEYMODULE_CMD_KEY_RM; uint64_t write_flags = - REDISMODULE_CMD_KEY_INSERT | REDISMODULE_CMD_KEY_DELETE | - REDISMODULE_CMD_KEY_UPDATE; + VALKEYMODULE_CMD_KEY_INSERT | VALKEYMODULE_CMD_KEY_DELETE | + VALKEYMODULE_CMD_KEY_UPDATE; if (!isPowerOfTwo(spec->flags & key_flags)) { serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].flags: " @@ -2065,9 +2066,9 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { } switch (spec->begin_search_type) { - case REDISMODULE_KSPEC_BS_UNKNOWN: break; - case REDISMODULE_KSPEC_BS_INDEX: break; - case REDISMODULE_KSPEC_BS_KEYWORD: + case VALKEYMODULE_KSPEC_BS_UNKNOWN: break; + case VALKEYMODULE_KSPEC_BS_INDEX: break; + case VALKEYMODULE_KSPEC_BS_KEYWORD: if (spec->bs.keyword.keyword == NULL) { serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].bs.keyword.keyword " @@ -2084,10 +2085,10 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { /* Validate find_keys_type. */ switch (spec->find_keys_type) { - case REDISMODULE_KSPEC_FK_OMITTED: break; /* short for RANGE {0,1,0} */ - case REDISMODULE_KSPEC_FK_UNKNOWN: break; - case REDISMODULE_KSPEC_FK_RANGE: break; - case REDISMODULE_KSPEC_FK_KEYNUM: break; + case VALKEYMODULE_KSPEC_FK_OMITTED: break; /* short for RANGE {0,1,0} */ + case VALKEYMODULE_KSPEC_FK_UNKNOWN: break; + case VALKEYMODULE_KSPEC_FK_RANGE: break; + case VALKEYMODULE_KSPEC_FK_KEYNUM: break; default: serverLog(LL_WARNING, "Invalid command info: key_specs[%zd].find_keys_type: " @@ -2101,22 +2102,22 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info) { return moduleValidateCommandArgs(info->args, version); } -/* When from_api is true, converts from REDISMODULE_CMD_KEY_* flags to CMD_KEY_* flags. - * When from_api is false, converts from CMD_KEY_* flags to REDISMODULE_CMD_KEY_* flags. */ +/* When from_api is true, converts from VALKEYMODULE_CMD_KEY_* flags to CMD_KEY_* flags. + * When from_api is false, converts from CMD_KEY_* flags to VALKEYMODULE_CMD_KEY_* flags. */ static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api) { int64_t out = 0; int64_t map[][2] = { - {REDISMODULE_CMD_KEY_RO, CMD_KEY_RO}, - {REDISMODULE_CMD_KEY_RW, CMD_KEY_RW}, - {REDISMODULE_CMD_KEY_OW, CMD_KEY_OW}, - {REDISMODULE_CMD_KEY_RM, CMD_KEY_RM}, - {REDISMODULE_CMD_KEY_ACCESS, CMD_KEY_ACCESS}, - {REDISMODULE_CMD_KEY_INSERT, CMD_KEY_INSERT}, - {REDISMODULE_CMD_KEY_UPDATE, CMD_KEY_UPDATE}, - {REDISMODULE_CMD_KEY_DELETE, CMD_KEY_DELETE}, - {REDISMODULE_CMD_KEY_NOT_KEY, CMD_KEY_NOT_KEY}, - {REDISMODULE_CMD_KEY_INCOMPLETE, CMD_KEY_INCOMPLETE}, - {REDISMODULE_CMD_KEY_VARIABLE_FLAGS, CMD_KEY_VARIABLE_FLAGS}, + {VALKEYMODULE_CMD_KEY_RO, CMD_KEY_RO}, + {VALKEYMODULE_CMD_KEY_RW, CMD_KEY_RW}, + {VALKEYMODULE_CMD_KEY_OW, CMD_KEY_OW}, + {VALKEYMODULE_CMD_KEY_RM, CMD_KEY_RM}, + {VALKEYMODULE_CMD_KEY_ACCESS, CMD_KEY_ACCESS}, + {VALKEYMODULE_CMD_KEY_INSERT, CMD_KEY_INSERT}, + {VALKEYMODULE_CMD_KEY_UPDATE, CMD_KEY_UPDATE}, + {VALKEYMODULE_CMD_KEY_DELETE, CMD_KEY_DELETE}, + {VALKEYMODULE_CMD_KEY_NOT_KEY, CMD_KEY_NOT_KEY}, + {VALKEYMODULE_CMD_KEY_INCOMPLETE, CMD_KEY_INCOMPLETE}, + {VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS, CMD_KEY_VARIABLE_FLAGS}, {0,0}}; int from_idx = from_api ? 0 : 1, to_idx = !from_idx; @@ -2125,13 +2126,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 ValkeyModuleCommandArg. Returns 1 if it's valid and 0 if * it's invalid. */ -static int moduleValidateCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static int moduleValidateCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *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); + ValkeyModuleCommandArg *arg = moduleCmdArgAt(version, args, j); int arg_type_error = 0; moduleConvertArgType(arg->type, &arg_type_error); if (arg_type_error) { @@ -2140,14 +2141,14 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, arg->name, arg->type); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_PURE_TOKEN && !arg->token) { + if (arg->type == VALKEYMODULE_ARG_TYPE_PURE_TOKEN && !arg->token) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": " "token required when type is PURE_TOKEN", args[j].name); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_KEY) { + if (arg->type == VALKEYMODULE_ARG_TYPE_KEY) { if (arg->key_spec_index < 0) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": " @@ -2165,15 +2166,15 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, return 0; } - if (arg->flags & ~(_REDISMODULE_CMD_ARG_NEXT - 1)) { + if (arg->flags & ~(_VALKEYMODULE_CMD_ARG_NEXT - 1)) { serverLog(LL_WARNING, "Invalid command info: Argument \"%s\": Invalid flags", arg->name); return 0; } - if (arg->type == REDISMODULE_ARG_TYPE_ONEOF || - arg->type == REDISMODULE_ARG_TYPE_BLOCK) + if (arg->type == VALKEYMODULE_ARG_TYPE_ONEOF || + arg->type == VALKEYMODULE_ARG_TYPE_BLOCK) { if (arg->subargs == NULL) { serverLog(LL_WARNING, @@ -2196,20 +2197,20 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args, return 1; } -/* Converts an array of RedisModuleCommandArg into a freshly allocated array of +/* Converts an array of ValkeyModuleCommandArg into a freshly allocated array of * struct serverCommandArg. */ -static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args, - const RedisModuleCommandInfoVersion *version) { +static struct serverCommandArg *moduleCopyCommandArgs(ValkeyModuleCommandArg *args, + const ValkeyModuleCommandInfoVersion *version) { size_t count = 0; while (moduleCmdArgAt(version, args, count)->name) count++; serverAssert(count < SIZE_MAX / sizeof(struct serverCommandArg)); struct serverCommandArg *realargs = zcalloc((count+1) * sizeof(serverCommandArg)); for (size_t j = 0; j < count; j++) { - RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j); + ValkeyModuleCommandArg *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) + if (arg->type == VALKEYMODULE_ARG_TYPE_KEY) realargs[j].key_spec_index = arg->key_spec_index; else realargs[j].key_spec_index = -1; @@ -2224,18 +2225,18 @@ static struct serverCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *arg return realargs; } -static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error) { +static serverCommandArgType moduleConvertArgType(ValkeyModuleCommandArgType type, int *error) { if (error) *error = 0; switch (type) { - case REDISMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; - case REDISMODULE_ARG_TYPE_INTEGER: return ARG_TYPE_INTEGER; - case REDISMODULE_ARG_TYPE_DOUBLE: return ARG_TYPE_DOUBLE; - case REDISMODULE_ARG_TYPE_KEY: return ARG_TYPE_KEY; - case REDISMODULE_ARG_TYPE_PATTERN: return ARG_TYPE_PATTERN; - case REDISMODULE_ARG_TYPE_UNIX_TIME: return ARG_TYPE_UNIX_TIME; - case REDISMODULE_ARG_TYPE_PURE_TOKEN: return ARG_TYPE_PURE_TOKEN; - case REDISMODULE_ARG_TYPE_ONEOF: return ARG_TYPE_ONEOF; - case REDISMODULE_ARG_TYPE_BLOCK: return ARG_TYPE_BLOCK; + case VALKEYMODULE_ARG_TYPE_STRING: return ARG_TYPE_STRING; + case VALKEYMODULE_ARG_TYPE_INTEGER: return ARG_TYPE_INTEGER; + case VALKEYMODULE_ARG_TYPE_DOUBLE: return ARG_TYPE_DOUBLE; + case VALKEYMODULE_ARG_TYPE_KEY: return ARG_TYPE_KEY; + case VALKEYMODULE_ARG_TYPE_PATTERN: return ARG_TYPE_PATTERN; + case VALKEYMODULE_ARG_TYPE_UNIX_TIME: return ARG_TYPE_UNIX_TIME; + case VALKEYMODULE_ARG_TYPE_PURE_TOKEN: return ARG_TYPE_PURE_TOKEN; + case VALKEYMODULE_ARG_TYPE_ONEOF: return ARG_TYPE_ONEOF; + case VALKEYMODULE_ARG_TYPE_BLOCK: return ARG_TYPE_BLOCK; default: if (error) *error = 1; return -1; @@ -2244,24 +2245,24 @@ static serverCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, static int moduleConvertArgFlags(int flags) { int realflags = 0; - if (flags & REDISMODULE_CMD_ARG_OPTIONAL) realflags |= CMD_ARG_OPTIONAL; - if (flags & REDISMODULE_CMD_ARG_MULTIPLE) realflags |= CMD_ARG_MULTIPLE; - if (flags & REDISMODULE_CMD_ARG_MULTIPLE_TOKEN) realflags |= CMD_ARG_MULTIPLE_TOKEN; + if (flags & VALKEYMODULE_CMD_ARG_OPTIONAL) realflags |= CMD_ARG_OPTIONAL; + if (flags & VALKEYMODULE_CMD_ARG_MULTIPLE) realflags |= CMD_ARG_MULTIPLE; + if (flags & VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN) realflags |= CMD_ARG_MULTIPLE_TOKEN; return realflags; } -/* Return `struct RedisModule *` as `void *` to avoid exposing it outside of module.c. */ +/* Return `struct ValkeyModule *` 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 serverCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) + if (cmd->proc != ValkeyModuleCommandDispatcher) return 0; if (module_handle == NULL) return 0; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; return (cp->module == module_handle); } @@ -2279,12 +2280,12 @@ void moduleListFree(void *config) { zfree(config); } -void RM_SetModuleAttribs(RedisModuleCtx *ctx, const char *name, int ver, int apiver) { - /* Called by RM_Init() to setup the `ctx->module` structure. +void VM_SetModuleAttribs(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) { + /* Called by VM_Init() to setup the `ctx->module` structure. * * This is an internal function, Redis modules developers don't need * to use it. */ - RedisModule *module; + ValkeyModule *module; if (ctx->module != NULL) return; module = zmalloc(sizeof(*module)); @@ -2313,7 +2314,7 @@ void RM_SetModuleAttribs(RedisModuleCtx *ctx, const char *name, int ver, int api /* Return non-zero if the module name is busy. * Otherwise zero is returned. */ -int RM_IsModuleNameBusy(const char *name) { +int VM_IsModuleNameBusy(const char *name) { sds modulename = sdsnew(name); dictEntry *de = dictFind(modules,modulename); sdsfree(modulename); @@ -2321,58 +2322,58 @@ int RM_IsModuleNameBusy(const char *name) { } /* Return the current UNIX time in milliseconds. */ -mstime_t RM_Milliseconds(void) { +mstime_t VM_Milliseconds(void) { return mstime(); } /* Return counter of micro-seconds relative to an arbitrary point in time. */ -uint64_t RM_MonotonicMicroseconds(void) { +uint64_t VM_MonotonicMicroseconds(void) { return getMonotonicUs(); } /* Return the current UNIX time in microseconds */ -ustime_t RM_Microseconds(void) { +ustime_t VM_Microseconds(void) { return ustime(); } /* 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 ValkeyModule_Call, * causing another notification, etc. * It makes sense that all this callbacks would use the same clock. */ -ustime_t RM_CachedMicroseconds(void) { +ustime_t VM_CachedMicroseconds(void) { return server.ustime; } /* Mark a point in time that will be used as the start time to calculate - * the elapsed execution time when RM_BlockedClientMeasureTimeEnd() is called. + * the elapsed execution time when VM_BlockedClientMeasureTimeEnd() is called. * Within the same command, you can call multiple times - * RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd() + * VM_BlockedClientMeasureTimeStart() and VM_BlockedClientMeasureTimeEnd() * to accumulate independent time intervals to the background duration. - * This method always return REDISMODULE_OK. + * This method always return VALKEYMODULE_OK. * * 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 VM_BlockedClientMeasureTimeStart(ValkeyModuleBlockedClient *bc) { elapsedStart(&(bc->background_timer)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Mark a point in time that will be used as the end time * to calculate the elapsed execution time. - * On success REDISMODULE_OK is returned. - * This method only returns REDISMODULE_ERR if no start time was - * previously defined ( meaning RM_BlockedClientMeasureTimeStart was not called ). + * On success VALKEYMODULE_OK is returned. + * This method only returns VALKEYMODULE_ERR if no start time was + * previously defined ( meaning VM_BlockedClientMeasureTimeStart was not called ). * * 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) { - // If the counter is 0 then we haven't called RM_BlockedClientMeasureTimeStart +int VM_BlockedClientMeasureTimeEnd(ValkeyModuleBlockedClient *bc) { + // If the counter is 0 then we haven't called VM_BlockedClientMeasureTimeStart if (!bc->background_timer) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; bc->background_duration += elapsedUs(bc->background_timer); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This API allows modules to let Redis process background tasks, and some @@ -2380,14 +2381,14 @@ int RM_BlockedClientMeasureTimeEnd(RedisModuleBlockedClient *bc) { * The module can call this API periodically. * The flags is a bit mask of these: * - * - `REDISMODULE_YIELD_FLAG_NONE`: No special flags, can perform some background + * - `VALKEYMODULE_YIELD_FLAG_NONE`: No special flags, can perform some background * operations, but not process client commands. - * - `REDISMODULE_YIELD_FLAG_CLIENTS`: Redis can also process client commands. + * - `VALKEYMODULE_YIELD_FLAG_CLIENTS`: Redis can also process client commands. * * The `busy_reply` argument is optional, and can be used to control the verbose * error string after the `-BUSY` error code. * - * When the `REDISMODULE_YIELD_FLAG_CLIENTS` is used, Redis will only start + * When the `VALKEYMODULE_YIELD_FLAG_CLIENTS` is used, Redis will only start * processing client commands after the time defined by the * `busy-reply-threshold` config, in which case Redis will start rejecting most * commands with `-BUSY` error, but allow the ones marked with the `allow-busy` @@ -2396,9 +2397,9 @@ 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 VM_Yield(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) { static int yield_nesting = 0; - /* Avoid nested calls to RM_Yield */ + /* Avoid nested calls to VM_Yield */ if (yield_nesting) return; yield_nesting++; @@ -2421,7 +2422,7 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { if (server.current_client) protectClient(server.current_client); } - if (flags & REDISMODULE_YIELD_FLAG_CLIENTS) + if (flags & VALKEYMODULE_YIELD_FLAG_CLIENTS) server.busy_module_yield_flags |= BUSY_MODULE_YIELD_CLIENTS; /* Let redis process events */ @@ -2468,28 +2469,28 @@ void RM_Yield(RedisModuleCtx *ctx, int flags, const char *busy_reply) { /* Set flags defining capabilities or behavior bit flags. * - * REDISMODULE_OPTIONS_HANDLE_IO_ERRORS: + * VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS: * 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 ValkeyModule_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. * - * REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED: - * See RM_SignalModifiedKey(). + * VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED: + * See VM_SignalModifiedKey(). * - * REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD: + * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD: * Setting this flag indicates module awareness of diskless async replication (repl-diskless-load=swapdb) * and that redis could be serving reads during replication instead of blocking with LOADING status. * - * REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS: + * VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS: * Declare that the module wants to get nested key-space notifications. * By default, Redis will not fire key-space notifications that happened inside * 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 VM_SetModuleOptions(ValkeyModuleCtx *ctx, int options) { ctx->module->options = options; } @@ -2497,12 +2498,12 @@ void RM_SetModuleOptions(RedisModuleCtx *ctx, int options) { * and client side caching). * * This is done automatically when a key opened for writing is closed, unless - * the option REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED has been set using - * RM_SetModuleOptions(). + * the option VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED has been set using + * VM_SetModuleOptions(). */ -int RM_SignalModifiedKey(RedisModuleCtx *ctx, RedisModuleString *keyname) { +int VM_SignalModifiedKey(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) { signalModifiedKey(ctx->client,ctx->client->db,keyname); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -2518,19 +2519,19 @@ 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. ValkeyModule_CloseKey() + * 2. ValkeyModule_FreeCallReply() + * 3. ValkeyModule_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) { - ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; +void VM_AutoMemory(ValkeyModuleCtx *ctx) { + ctx->flags |= VALKEYMODULE_CTX_AUTO_MEMORY; } /* Add a new object to release automatically when the callback returns. */ -void autoMemoryAdd(RedisModuleCtx *ctx, int type, void *ptr) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; +void autoMemoryAdd(ValkeyModuleCtx *ctx, int type, void *ptr) { + if (!(ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY)) return; if (ctx->amqueue_used == ctx->amqueue_len) { ctx->amqueue_len *= 2; if (ctx->amqueue_len < 16) ctx->amqueue_len = 16; @@ -2546,8 +2547,8 @@ 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) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return 0; +int autoMemoryFreed(ValkeyModuleCtx *ctx, int type, void *ptr) { + if (!(ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY)) return 0; int count = (ctx->amqueue_used+1)/2; for (int j = 0; j < count; j++) { @@ -2558,7 +2559,7 @@ int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { if (ctx->amqueue[i].type == type && ctx->amqueue[i].ptr == ptr) { - ctx->amqueue[i].type = REDISMODULE_AM_FREED; + ctx->amqueue[i].type = VALKEYMODULE_AM_FREED; /* Switch the freed element and the last element, to avoid growing * the queue unnecessarily if we allocate/free in a loop */ @@ -2577,24 +2578,24 @@ int autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) { } /* Release all the objects in queue. */ -void autoMemoryCollect(RedisModuleCtx *ctx) { - if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return; +void autoMemoryCollect(ValkeyModuleCtx *ctx) { + if (!(ctx->flags & VALKEYMODULE_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 * queue to mark the entries as freed. */ - ctx->flags &= ~REDISMODULE_CTX_AUTO_MEMORY; + ctx->flags &= ~VALKEYMODULE_CTX_AUTO_MEMORY; int j; for (j = 0; j < ctx->amqueue_used; j++) { void *ptr = ctx->amqueue[j].ptr; switch(ctx->amqueue[j].type) { - case REDISMODULE_AM_STRING: decrRefCount(ptr); break; - case REDISMODULE_AM_REPLY: RM_FreeCallReply(ptr); break; - case REDISMODULE_AM_KEY: RM_CloseKey(ptr); break; - case REDISMODULE_AM_DICT: RM_FreeDict(NULL,ptr); break; - case REDISMODULE_AM_INFO: RM_FreeServerInfo(NULL,ptr); break; + case VALKEYMODULE_AM_STRING: decrRefCount(ptr); break; + case VALKEYMODULE_AM_REPLY: VM_FreeCallReply(ptr); break; + case VALKEYMODULE_AM_KEY: VM_CloseKey(ptr); break; + case VALKEYMODULE_AM_DICT: VM_FreeDict(NULL,ptr); break; + case VALKEYMODULE_AM_INFO: VM_FreeServerInfo(NULL,ptr); break; } } - ctx->flags |= REDISMODULE_CTX_AUTO_MEMORY; + ctx->flags |= VALKEYMODULE_CTX_AUTO_MEMORY; zfree(ctx->amqueue); ctx->amqueue = NULL; ctx->amqueue_len = 0; @@ -2606,7 +2607,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 ValkeyModule_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. @@ -2615,21 +2616,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); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); +ValkeyModuleString *VM_CreateString(ValkeyModuleCtx *ctx, const char *ptr, size_t len) { + ValkeyModuleString *o = createStringObject(ptr,len); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_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 ValkeyModule_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, ...) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringPrintf(ValkeyModuleCtx *ctx, const char *fmt, ...) { sds s = sdsempty(); va_list ap; @@ -2637,90 +2638,90 @@ RedisModuleString *RM_CreateStringPrintf(RedisModuleCtx *ctx, const char *fmt, . s = sdscatvprintf(s, fmt, ap); va_end(ap); - RedisModuleString *o = createObject(OBJ_STRING, s); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + ValkeyModuleString *o = createObject(OBJ_STRING, s); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,o); return o; } -/* Like RedisModule_CreateString(), but creates a string starting from a `long long` +/* Like ValkeyModule_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 ValkeyModule_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) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromLongLong(ValkeyModuleCtx *ctx, long long ll) { char buf[LONG_STR_SIZE]; size_t len = ll2string(buf,sizeof(buf),ll); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a `unsigned long long` +/* Like ValkeyModule_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 ValkeyModule_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) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromULongLong(ValkeyModuleCtx *ctx, unsigned long long ull) { char buf[LONG_STR_SIZE]; size_t len = ull2string(buf,sizeof(buf),ull); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a double +/* Like ValkeyModule_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 ValkeyModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_CreateStringFromDouble(RedisModuleCtx *ctx, double d) { +ValkeyModuleString *VM_CreateStringFromDouble(ValkeyModuleCtx *ctx, double d) { char buf[MAX_D2STRING_CHARS]; size_t len = d2string(buf,sizeof(buf),d); - return RM_CreateString(ctx,buf,len); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from a long +/* Like ValkeyModule_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 ValkeyModule_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) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromLongDouble(ValkeyModuleCtx *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); + return VM_CreateString(ctx,buf,len); } -/* Like RedisModule_CreateString(), but creates a string starting from another - * RedisModuleString. +/* Like ValkeyModule_CreateString(), but creates a string starting from another + * ValkeyModuleString. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_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); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromString(ValkeyModuleCtx *ctx, const ValkeyModuleString *str) { + ValkeyModuleString *o = dupStringObject(str); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_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. + * ValkeyModule_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) { + * ValkeyModule_CreateString() documentation for more info. */ +ValkeyModuleString *VM_CreateStringFromStreamID(ValkeyModuleCtx *ctx, const ValkeyModuleStreamID *id) { streamID streamid = {id->ms, id->seq}; - RedisModuleString *o = createObjectFromStreamID(&streamid); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, o); + ValkeyModuleString *o = createObjectFromStreamID(&streamid); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, o); return o; } @@ -2739,16 +2740,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 VM_FreeString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { decrRefCount(str); - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str); + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_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 ValkeyModule_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). + * ValkeyModule_FreeString() call (it is just executed automatically). * * Normally you want to call this function when, at the same time * the following conditions are true: @@ -2770,7 +2771,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 ValkeyModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference retained strings from other threads *must* @@ -2779,8 +2780,8 @@ 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) { - if (ctx == NULL || !autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str)) { +void VM_RetainString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { + if (ctx == NULL || !autoMemoryFreed(ctx,VALKEYMODULE_AM_STRING,str)) { /* Increment the string reference counting only if we can't * just remove the object from the list of objects that should * be reclaimed. Why we do that, instead of just incrementing @@ -2789,33 +2790,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 ValkeyModule_StringAppendBuffer() to work. */ incrRefCount(str); } } /** -* This function can be used instead of RedisModule_RetainString(). +* This function can be used instead of ValkeyModule_RetainString(). * The main difference between the two is that this function will always -* succeed, whereas RedisModule_RetainString() may fail because of an +* succeed, whereas ValkeyModule_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 ValkeyModuleString, which is owned +* by the caller. It requires a call to ValkeyModule_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. +* ValkeyModule_FreeString() or let the automation free it. * -* This function is more efficient than RedisModule_CreateStringFromString() +* This function is more efficient than ValkeyModule_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. +* ValkeyModuleString. The disadvantage of using this function is that it +* might not be possible to use ValkeyModule_StringAppendBuffer() on the +* returned ValkeyModuleString. * * 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 ValkeyModule_TrimStringAllocation() in order to * optimize memory usage. * * Threaded modules that reference held strings from other threads *must* @@ -2824,9 +2825,9 @@ 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) { +ValkeyModuleString* VM_HoldString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { if (str->refcount == OBJ_STATIC_REFCOUNT) { - return RM_CreateStringFromString(ctx, str); + return VM_CreateStringFromString(ctx, str); } incrRefCount(str); @@ -2838,27 +2839,27 @@ RedisModuleString* RM_HoldString(RedisModuleCtx *ctx, RedisModuleString *str) { * object in the auto memory free function. * * Why we can not do the same trick of just remove the object - * from the auto memory (like in RM_RetainString)? + * from the auto memory (like in VM_RetainString)? * This code shows the issue: * - * RM_AutoMemory(ctx); - * str1 = RM_CreateString(ctx, "test", 4); - * str2 = RM_HoldString(ctx, str1); - * RM_FreeString(str1); - * RM_FreeString(str2); + * VM_AutoMemory(ctx); + * str1 = VM_CreateString(ctx, "test", 4); + * str2 = VM_HoldString(ctx, str1); + * VM_FreeString(str1); + * VM_FreeString(str2); * - * If after the RM_HoldString we would just remove the string from + * If after the VM_HoldString we would just remove the string from * the auto memory, this example will cause access to a freed memory - * on 'RM_FreeString(str2);' because the String will be free - * on 'RM_FreeString(str1);'. + * on 'VM_FreeString(str2);' because the String will be free + * on 'VM_FreeString(str1);'. * * 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 ValkeyModule_StringAppendBuffer * on the String. */ - autoMemoryAdd(ctx,REDISMODULE_AM_STRING,str); + autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,str); } return str; } @@ -2866,7 +2867,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 *VM_StringPtrLen(const ValkeyModuleString *str, size_t *len) { if (str == NULL) { const char *errmsg = "(NULL string reply referenced in module)"; if (len) *len = strlen(errmsg); @@ -2881,64 +2882,64 @@ const char *RM_StringPtrLen(const RedisModuleString *str, size_t *len) { * ------------------------------------------------------------------------- */ /* Convert the string into a `long long` integer, storing it at `*ll`. - * Returns REDISMODULE_OK on success. If the string can't be parsed - * as a valid, strict `long long` (no spaces before/after), REDISMODULE_ERR + * Returns VALKEYMODULE_OK on success. If the string can't be parsed + * as a valid, strict `long long` (no spaces before/after), VALKEYMODULE_ERR * is returned. */ -int RM_StringToLongLong(const RedisModuleString *str, long long *ll) { - return string2ll(str->ptr,sdslen(str->ptr),ll) ? REDISMODULE_OK : - REDISMODULE_ERR; +int VM_StringToLongLong(const ValkeyModuleString *str, long long *ll) { + return string2ll(str->ptr,sdslen(str->ptr),ll) ? VALKEYMODULE_OK : + VALKEYMODULE_ERR; } /* Convert the string into a `unsigned long long` integer, storing it at `*ull`. - * 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 + * Returns VALKEYMODULE_OK on success. If the string can't be parsed + * as a valid, strict `unsigned long long` (no spaces before/after), VALKEYMODULE_ERR * is returned. */ -int RM_StringToULongLong(const RedisModuleString *str, unsigned long long *ull) { - return string2ull(str->ptr,ull) ? REDISMODULE_OK : REDISMODULE_ERR; +int VM_StringToULongLong(const ValkeyModuleString *str, unsigned long long *ull) { + return string2ull(str->ptr,ull) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a double, storing it at `*d`. - * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is + * Returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToDouble(const RedisModuleString *str, double *d) { +int VM_StringToDouble(const ValkeyModuleString *str, double *d) { int retval = getDoubleFromObject(str,d); - return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == C_OK) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a long double, storing it at `*ld`. - * Returns REDISMODULE_OK on success or REDISMODULE_ERR if the string is + * Returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if the string is * not a valid string representation of a double value. */ -int RM_StringToLongDouble(const RedisModuleString *str, long double *ld) { +int VM_StringToLongDouble(const ValkeyModuleString *str, long double *ld) { int retval = string2ld(str->ptr,sdslen(str->ptr),ld); - return retval ? REDISMODULE_OK : REDISMODULE_ERR; + return retval ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Convert the string into a stream ID, storing it at `*id`. - * Returns REDISMODULE_OK on success and returns REDISMODULE_ERR if the string + * Returns VALKEYMODULE_OK on success and returns VALKEYMODULE_ERR if the string * 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 VM_StringToStreamID(const ValkeyModuleString *str, ValkeyModuleStreamID *id) { streamID streamid; if (streamParseID(str, &streamid) == C_OK) { id->ms = streamid.ms; id->seq = streamid.seq; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* 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 VM_StringCompare(const ValkeyModuleString *a, const ValkeyModuleString *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) { +ValkeyModuleString *moduleAssertUnsharedString(ValkeyModuleString *str) { if (str->refcount != 1) { serverLog(LL_WARNING, "Module attempted to use an in-place string modify operation " @@ -2961,18 +2962,18 @@ 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) { + * VALKEYMODULE_ERR is returned and the operation is not performed. */ +int VM_StringAppendBuffer(ValkeyModuleCtx *ctx, ValkeyModuleString *str, const char *buf, size_t len) { UNUSED(ctx); str = moduleAssertUnsharedString(str); - if (str == NULL) return REDISMODULE_ERR; + if (str == NULL) return VALKEYMODULE_ERR; str->ptr = sdscatlen(str->ptr,buf,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Trim possible excess memory allocated for a RedisModuleString. +/* Trim possible excess memory allocated for a ValkeyModuleString. * - * Sometimes a RedisModuleString may have more memory allocated for + * Sometimes a ValkeyModuleString 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 @@ -2993,7 +2994,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 VM_TrimStringAllocation(ValkeyModuleString *str) { if (!str) return; trimStringObjectIfNeeded(str, 1); } @@ -3003,11 +3004,11 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * * These functions are used for sending replies to the client. * - * Most functions always return REDISMODULE_OK so you can use it with + * Most functions always return VALKEYMODULE_OK so you can use it with * 'return' in order to return from the command implementation with: * * if (... some condition ...) - * return RedisModule_ReplyWithLongLong(ctx,mycount); + * return ValkeyModule_ReplyWithLongLong(ctx,mycount); * * ### Reply with collection functions * @@ -3017,24 +3018,24 @@ void RM_TrimStringAllocation(RedisModuleString *str) { * * When producing collections with a number of elements that is not known * beforehand, the function can be called with a special flag - * REDISMODULE_POSTPONED_LEN (REDISMODULE_POSTPONED_ARRAY_LEN in the past), - * and the actual number of elements can be later set with RM_ReplySet*Length() + * VALKEYMODULE_POSTPONED_LEN (VALKEYMODULE_POSTPONED_ARRAY_LEN in the past), + * and the actual number of elements can be later set with VM_ReplySet*Length() * call (which will set the latest "open" count if there are multiple ones). * -------------------------------------------------------------------------- */ /* Send an error about the number of arguments given to the command, - * citing the command name in the error message. Returns REDISMODULE_OK. + * citing the command name in the error message. Returns VALKEYMODULE_OK. * * Example: * - * if (argc != 3) return RedisModule_WrongArity(ctx); + * if (argc != 3) return ValkeyModule_WrongArity(ctx); */ -int RM_WrongArity(RedisModuleCtx *ctx) { +int VM_WrongArity(ValkeyModuleCtx *ctx) { addReplyErrorArity(ctx->client); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Return the client object the `RM_Reply*` functions should target. +/* Return the client object the `VM_Reply*` functions should target. * Normally this is just `ctx->client`, that is the client that called * the module command, however in the case of thread safe contexts there * is no directly associated client (since it would not be safe to access @@ -3048,8 +3049,8 @@ 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) { - if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) { +client *moduleGetReplyClient(ValkeyModuleCtx *ctx) { + if (ctx->flags & VALKEYMODULE_CTX_THREAD_SAFE) { if (ctx->blocked_client) return ctx->blocked_client->reply_client; else @@ -3064,12 +3065,12 @@ 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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithLongLong(ValkeyModuleCtx *ctx, long long ll) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyLongLong(c,ll); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with the error 'err'. @@ -3078,19 +3079,19 @@ 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"); + * ValkeyModule_ReplyWithError(ctx,"ERR Wrong Type"); * * and not just: * - * RedisModule_ReplyWithError(ctx,"Wrong Type"); + * ValkeyModule_ReplyWithError(ctx,"Wrong Type"); * - * The function always returns REDISMODULE_OK. + * The function always returns VALKEYMODULE_OK. */ -int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) { +int VM_ReplyWithError(ValkeyModuleCtx *ctx, const char *err) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyErrorFormat(c,"-%s",err); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with the error create from a printf format and arguments. @@ -3099,17 +3100,17 @@ 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); + * ValkeyModule_ReplyWithErrorFormat(ctx,"ERR Wrong Type: %s",type); * * and not just: * - * RedisModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); + * ValkeyModule_ReplyWithErrorFormat(ctx,"Wrong Type: %s",type); * - * The function always returns REDISMODULE_OK. + * The function always returns VALKEYMODULE_OK. */ -int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { +int VM_ReplyWithErrorFormat(ValkeyModuleCtx *ctx, const char *fmt, ...) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; int len = strlen(fmt) + 2; /* 1 for the \0 and 1 for the hyphen */ char *hyphenfmt = zmalloc(len); @@ -3122,21 +3123,21 @@ int RM_ReplyWithErrorFormat(RedisModuleCtx *ctx, const char *fmt, ...) { zfree(hyphenfmt); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a simple string (`+... \r\n` in RESP protocol). This replies * are suitable only when sending a small non-binary string with small * overhead, like "OK" or similar replies. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithSimpleString(ValkeyModuleCtx *ctx, const char *msg) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyProto(c,"+",1); addReplyProto(c,msg,strlen(msg)); addReplyProto(c,"\r\n",2); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } #define COLLECTION_REPLY_ARRAY 1 @@ -3144,10 +3145,10 @@ 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(ValkeyModuleCtx *ctx, long len, int type) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; - if (len == REDISMODULE_POSTPONED_LEN) { + if (c == NULL) return VALKEYMODULE_OK; + if (len == VALKEYMODULE_POSTPONED_LEN) { ctx->postponed_arrays = zrealloc(ctx->postponed_arrays,sizeof(void*)* (ctx->postponed_arrays_count+1)); ctx->postponed_arrays[ctx->postponed_arrays_count] = @@ -3187,7 +3188,7 @@ int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { serverPanic("Invalid module reply type %d", type); } } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with an array type of 'len' elements. @@ -3196,10 +3197,10 @@ int moduleReplyWithCollection(RedisModuleCtx *ctx, long len, int type) { * `ReplyWith*` style functions in order to emit the elements of the array. * See Reply APIs section for more details. * - * Use RM_ReplySetArrayLength() to set deferred length. + * Use VM_ReplySetArrayLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithArray(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ARRAY); } @@ -3213,10 +3214,10 @@ int RM_ReplyWithArray(RedisModuleCtx *ctx, long len) { * If the connected client is using RESP2, the reply will be converted to a flat * array. * - * Use RM_ReplySetMapLength() to set deferred length. + * Use VM_ReplySetMapLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithMap(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_MAP); } @@ -3230,10 +3231,10 @@ int RM_ReplyWithMap(RedisModuleCtx *ctx, long len) { * If the connected client is using RESP2, the reply will be converted to an * array type. * - * Use RM_ReplySetSetLength() to set deferred length. + * Use VM_ReplySetSetLength() to set deferred length. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithSet(ValkeyModuleCtx *ctx, long len) { return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_SET); } @@ -3245,12 +3246,12 @@ int RM_ReplyWithSet(RedisModuleCtx *ctx, long len) { * `ReplyWith*` style functions in order to emit the elements of the attribute map. * See Reply APIs section for more details. * - * Use RM_ReplySetAttributeLength() to set deferred length. + * Use VM_ReplySetAttributeLength() to set deferred length. * - * Not supported by RESP2 and will return REDISMODULE_ERR, otherwise - * the function always returns REDISMODULE_OK. */ -int RM_ReplyWithAttribute(RedisModuleCtx *ctx, long len) { - if (ctx->client->resp == 2) return REDISMODULE_ERR; + * Not supported by RESP2 and will return VALKEYMODULE_ERR, otherwise + * the function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithAttribute(ValkeyModuleCtx *ctx, long len) { + if (ctx->client->resp == 2) return VALKEYMODULE_ERR; return moduleReplyWithCollection(ctx, len, COLLECTION_REPLY_ATTRIBUTE); } @@ -3260,34 +3261,34 @@ 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 ValkeyModule_ReplyWithNull instead. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNullArray(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithNullArray(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyNullArray(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply to the client with an empty array. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyArray(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithEmptyArray(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReply(c,shared.emptyarray); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { +void moduleReplySetCollectionLength(ValkeyModuleCtx *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) " + "ValkeyModule_ReplySet*Length() called without previous " + "ValkeyModule_ReplyWith*(ctx,VALKEYMODULE_POSTPONED_LEN) " "call.", ctx->module->name); return; } @@ -3314,8 +3315,8 @@ void moduleReplySetCollectionLength(RedisModuleCtx *ctx, long len, int type) { } } -/* When RedisModule_ReplyWithArray() is used with the argument - * REDISMODULE_POSTPONED_LEN, because we don't know beforehand the number +/* When ValkeyModule_ReplyWithArray() is used with the argument + * VALKEYMODULE_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. * @@ -3326,115 +3327,115 @@ 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 + * ValkeyModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); + * ValkeyModule_ReplyWithLongLong(ctx,1); + * ValkeyModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); + * ValkeyModule_ReplyWithLongLong(ctx,10); + * ValkeyModule_ReplyWithLongLong(ctx,20); + * ValkeyModule_ReplyWithLongLong(ctx,30); + * ValkeyModule_ReplySetArrayLength(ctx,3); // Set len of 10,20,30 array. + * ValkeyModule_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 VM_ReplySetArrayLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ARRAY); } -/* Very similar to RedisModule_ReplySetArrayLength except `len` should +/* Very similar to ValkeyModule_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 VM_ReplySetMapLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_MAP); } -/* Very similar to RedisModule_ReplySetArrayLength +/* Very similar to ValkeyModule_ReplySetArrayLength * Visit https://github.com/antirez/RESP3/blob/master/spec.md for more info about RESP3. */ -void RM_ReplySetSetLength(RedisModuleCtx *ctx, long len) { +void VM_ReplySetSetLength(ValkeyModuleCtx *ctx, long len) { moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_SET); } -/* Very similar to RedisModule_ReplySetMapLength +/* Very similar to ValkeyModule_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) { + * Must not be called if VM_ReplyWithAttribute returned an error. */ +void VM_ReplySetAttributeLength(ValkeyModuleCtx *ctx, long len) { if (ctx->client->resp == 2) return; moduleReplySetCollectionLength(ctx, len, COLLECTION_REPLY_ATTRIBUTE); } /* 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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithStringBuffer(ValkeyModuleCtx *ctx, const char *buf, size_t len) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulkCBuffer(c,(char*)buf,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a bulk string, taking in input a C buffer pointer that is * assumed to be null-terminated. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithCString(RedisModuleCtx *ctx, const char *buf) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithCString(ValkeyModuleCtx *ctx, const char *buf) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulkCString(c,(char*)buf); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Reply with a bulk string, taking in input a RedisModuleString object. +/* Reply with a bulk string, taking in input a ValkeyModuleString object. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithString(RedisModuleCtx *ctx, RedisModuleString *str) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithString(ValkeyModuleCtx *ctx, ValkeyModuleString *str) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBulk(c,str); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with an empty string. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithEmptyString(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithEmptyString(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReply(c,shared.emptybulk); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a binary safe string, which should not be escaped or filtered * 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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithVerbatimStringType(ValkeyModuleCtx *ctx, const char *buf, size_t len, const char *ext) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyVerbatim(c, buf, len, ext); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a binary safe string, which should not be escaped or filtered * 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) { - return RM_ReplyWithVerbatimStringType(ctx, buf, len, "txt"); + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithVerbatimString(ValkeyModuleCtx *ctx, const char *buf, size_t len) { + return VM_ReplyWithVerbatimStringType(ctx, buf, len, "txt"); } /* Reply to the client with a NULL. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplyWithNull(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithNull(ValkeyModuleCtx *ctx) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyNull(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 Boolean type. @@ -3443,34 +3444,34 @@ int RM_ReplyWithNull(RedisModuleCtx *ctx) { * In RESP3, this is boolean type * 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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithBool(ValkeyModuleCtx *ctx, int b) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBool(c,b); - return REDISMODULE_OK; + return VALKEYMODULE_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 ValkeyModule_Call(). + * This function is useful when we use ValkeyModule_Call() in order to * execute some command, as we want to reply to the client exactly the * same reply we obtained by the command. * * Return: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if the given reply is in RESP3 format but the client expects RESP2. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if the given reply is in RESP3 format but the client expects RESP2. * 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 `VM_Call` so that the ValkeyModuleCallReply 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 VM_ReplyWithCallReply(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; if (c->resp == 2 && callReplyIsResp3(reply)) { /* The reply is in RESP3 format and the client is RESP2, * so it isn't possible to send this reply to the client. */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } size_t proto_len; const char *proto = callReplyGetProto(reply, &proto_len); @@ -3484,7 +3485,7 @@ int RM_ReplyWithCallReply(RedisModuleCtx *ctx, RedisModuleCallReply *reply) { list *errors = callReplyDeferredErrorList(reply); if (errors) deferredAfterErrorReply(c, errors); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 Double type. @@ -3493,17 +3494,17 @@ 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. + * ValkeyModule_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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithDouble(ValkeyModuleCtx *ctx, double d) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyDouble(c,d); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Reply with a RESP3 BigNumber type. @@ -3513,27 +3514,27 @@ int RM_ReplyWithDouble(RedisModuleCtx *ctx, double d) { * however, it's up to the caller to ensure that it's a valid BigNumber. * 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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithBigNumber(ValkeyModuleCtx *ctx, const char *bignum, size_t len) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyBigNum(c, bignum, len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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. + * ValkeyModule_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) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplyWithLongDouble(ValkeyModuleCtx *ctx, long double ld) { client *c = moduleGetReplyClient(ctx); - if (c == NULL) return REDISMODULE_OK; + if (c == NULL) return VALKEYMODULE_OK; addReplyHumanLongDouble(c, ld); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -3545,17 +3546,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 ValkeyModule_Call() + * are the first items, the ones replicated with ValkeyModule_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 ValkeyModule_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 ValkeyModule_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. @@ -3575,29 +3576,29 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) { * * #### Return value * - * The command returns REDISMODULE_ERR if the format specifiers are invalid + * The command returns VALKEYMODULE_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 VM_Replicate(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { struct serverCommand *cmd; robj **argv = NULL; int argc = 0, flags = 0, j; va_list ap; cmd = lookupCommandByCString((char*)cmdname); - if (!cmd) return REDISMODULE_ERR; + if (!cmd) return VALKEYMODULE_ERR; /* Create the client and dispatch the command. */ va_start(ap, fmt); argv = moduleCreateArgvFromUserFormat(cmdname,fmt,&argc,&flags,ap); va_end(ap); - if (argv == NULL) return REDISMODULE_ERR; + if (argv == NULL) return VALKEYMODULE_ERR; /* Select the propagation target. Usually is AOF + replicas, however * the caller can exclude one or the other using the "A" or "R" * modifiers. */ int target = 0; - if (!(flags & REDISMODULE_ARGV_NO_AOF)) target |= PROPAGATE_AOF; - if (!(flags & REDISMODULE_ARGV_NO_REPLICAS)) target |= PROPAGATE_REPL; + if (!(flags & VALKEYMODULE_ARGV_NO_AOF)) target |= PROPAGATE_AOF; + if (!(flags & VALKEYMODULE_ARGV_NO_REPLICAS)) target |= PROPAGATE_REPL; alsoPropagate(ctx->client->db->id,argv,argc,target); @@ -3605,7 +3606,7 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) for (j = 0; j < argc; j++) decrRefCount(argv[j]); zfree(argv); server.dirty++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function will replicate the command exactly as it was invoked @@ -3618,13 +3619,13 @@ int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) * the command can just be re-executed to deterministically re-create the * new state starting from the old one. * - * The function always returns REDISMODULE_OK. */ -int RM_ReplicateVerbatim(RedisModuleCtx *ctx) { + * The function always returns VALKEYMODULE_OK. */ +int VM_ReplicateVerbatim(ValkeyModuleCtx *ctx) { alsoPropagate(ctx->client->db->id, ctx->client->argv,ctx->client->argc, PROPAGATE_AOF|PROPAGATE_REPL); server.dirty++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -3646,20 +3647,20 @@ 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 (ValkeyModule_IsAOFClient(ValkeyModule_GetClientId(ctx)) { * // Handle it differently. * } */ -unsigned long long RM_GetClientId(RedisModuleCtx *ctx) { +unsigned long long VM_GetClientId(ValkeyModuleCtx *ctx) { if (ctx->client == NULL) return 0; return ctx->client->id; } /* Return the ACL user name used by the client with the specified client ID. - * Client ID can be obtained with RM_GetClientId() API. If the client does not + * Client ID can be obtained with VM_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) { +ValkeyModuleString *VM_GetClientUserNameById(ValkeyModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; @@ -3673,52 +3674,52 @@ RedisModuleString *RM_GetClientUserNameById(RedisModuleCtx *ctx, uint64_t id) { sds name = sdsnew(client->user->name); robj *str = createObject(OBJ_STRING, name); - autoMemoryAdd(ctx, REDISMODULE_AM_STRING, str); + autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, str); return str; } -/* This is a helper for RM_GetClientInfoById() and other functions: given +/* This is a helper for VM_GetClientInfoById() and other functions: given * a client, it populates the client info structure with the appropriate * fields depending on the version provided. If the version is not valid - * then REDISMODULE_ERR is returned. Otherwise the function returns - * REDISMODULE_OK and the structure pointed by 'ci' gets populated. */ + * then VALKEYMODULE_ERR is returned. Otherwise the function returns + * VALKEYMODULE_OK and the structure pointed by 'ci' gets populated. */ int modulePopulateClientInfoStructure(void *ci, client *client, int structver) { - if (structver != 1) return REDISMODULE_ERR; + if (structver != 1) return VALKEYMODULE_ERR; - RedisModuleClientInfoV1 *ci1 = ci; + ValkeyModuleClientInfoV1 *ci1 = ci; memset(ci1,0,sizeof(*ci1)); ci1->version = structver; if (client->flags & CLIENT_MULTI) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_MULTI; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_MULTI; if (client->flags & CLIENT_PUBSUB) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_PUBSUB; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB; if (client->flags & CLIENT_UNIX_SOCKET) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET; if (client->flags & CLIENT_TRACKING) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_TRACKING; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_TRACKING; if (client->flags & CLIENT_BLOCKED) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_BLOCKED; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED; if (client->conn->type == connectionTypeTls()) - ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_SSL; + ci1->flags |= VALKEYMODULE_CLIENTINFO_FLAG_SSL; int port; connAddrPeerName(client->conn,ci1->addr,sizeof(ci1->addr),&port); ci1->port = port; ci1->db = client->db->id; ci1->id = client->id; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a helper for moduleFireServerEvent() and other functions: * It populates the replication info structure with the appropriate * fields depending on the version provided. If the version is not valid - * then REDISMODULE_ERR is returned. Otherwise the function returns - * REDISMODULE_OK and the structure pointed by 'ri' gets populated. */ + * then VALKEYMODULE_ERR is returned. Otherwise the function returns + * VALKEYMODULE_OK and the structure pointed by 'ri' gets populated. */ int modulePopulateReplicationInfoStructure(void *ri, int structver) { - if (structver != 1) return REDISMODULE_ERR; + if (structver != 1) return VALKEYMODULE_ERR; - RedisModuleReplicationInfoV1 *ri1 = ri; + ValkeyModuleReplicationInfoV1 *ri1 = ri; memset(ri1,0,sizeof(*ri1)); ri1->version = structver; ri1->master = server.masterhost==NULL; @@ -3728,20 +3729,20 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { ri1->replid2 = server.replid2; ri1->repl1_offset = server.master_repl_offset; ri1->repl2_offset = server.second_replid_offset; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return information about the client with the specified ID (that was - * previously obtained via the RedisModule_GetClientId() API). If the - * client exists, REDISMODULE_OK is returned, otherwise REDISMODULE_ERR + * previously obtained via the ValkeyModule_GetClientId() API). If the + * client exists, VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_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 - * the correct REDISMODULE_CLIENTINFO_INITIALIZER_V1, the structure is populated + * a structure of type ValkeyModuleClientInfoV1, previously initialized with + * the correct VALKEYMODULE_CLIENTINFO_INITIALIZER_V1, the structure is populated * with the following fields: * - * uint64_t flags; // REDISMODULE_CLIENTINFO_FLAG_* + * uint64_t flags; // VALKEYMODULE_CLIENTINFO_FLAG_* * uint64_t id; // Client ID * char addr[46]; // IPv4 or IPv6 address. * uint16_t port; // TCP port. @@ -3754,12 +3755,12 @@ int modulePopulateReplicationInfoStructure(void *ri, int structver) { * * With flags having the following meaning: * - * REDISMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection. - * REDISMODULE_CLIENTINFO_FLAG_PUBSUB Client in Pub/Sub mode. - * REDISMODULE_CLIENTINFO_FLAG_BLOCKED Client blocked in command. - * REDISMODULE_CLIENTINFO_FLAG_TRACKING Client with keys tracking on. - * REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET Client using unix domain socket. - * REDISMODULE_CLIENTINFO_FLAG_MULTI Client in MULTI state. + * VALKEYMODULE_CLIENTINFO_FLAG_SSL Client using SSL connection. + * VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB Client in Pub/Sub mode. + * VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED Client blocked in command. + * VALKEYMODULE_CLIENTINFO_FLAG_TRACKING Client with keys tracking on. + * VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET Client using unix domain socket. + * VALKEYMODULE_CLIENTINFO_FLAG_MULTI Client in MULTI state. * * However passing NULL is a way to just check if the client exists in case * we are not interested in any additional information. @@ -3767,16 +3768,16 @@ 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); - * if (retval == REDISMODULE_OK) { + * ValkeyModuleClientInfo ci = VALKEYMODULE_CLIENTINFO_INITIALIZER; + * int retval = ValkeyModule_GetClientInfoById(&ci,client_id); + * if (retval == VALKEYMODULE_OK) { * printf("Address: %s\n", ci.addr); * } */ -int RM_GetClientInfoById(void *ci, uint64_t id) { +int VM_GetClientInfoById(void *ci, uint64_t id) { client *client = lookupClientByID(id); - if (client == NULL) return REDISMODULE_ERR; - if (ci == NULL) return REDISMODULE_OK; + if (client == NULL) return VALKEYMODULE_ERR; + if (ci == NULL) return VALKEYMODULE_OK; /* Fill the info structure if passed. */ uint64_t structver = ((uint64_t*)ci)[0]; @@ -3787,50 +3788,50 @@ 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) { +ValkeyModuleString *VM_GetClientNameById(ValkeyModuleCtx *ctx, uint64_t id) { client *client = lookupClientByID(id); if (client == NULL || client->name == NULL) return NULL; robj *name = client->name; incrRefCount(name); - autoMemoryAdd(ctx, REDISMODULE_AM_STRING, name); + autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, name); return name; } /* Sets the name of the client with the given ID. This is equivalent to the client calling * `CLIENT SETNAME name`. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and errno is set as follows: * * - ENOENT if the client does not exist * - EINVAL if the name contains invalid characters */ -int RM_SetClientNameById(uint64_t id, RedisModuleString *name) { +int VM_SetClientNameById(uint64_t id, ValkeyModuleString *name) { client *client = lookupClientByID(id); if (client == NULL) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (clientSetName(client, name, NULL) == C_ERR) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Publish a message to subscribers (see PUBLISH command). */ -int RM_PublishMessage(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message) { +int VM_PublishMessage(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *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 VM_PublishMessageShard(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) { UNUSED(ctx); return pubsubPublishMessageAndPropagateToCluster(channel, message, 1); } /* Return the currently selected DB. */ -int RM_GetSelectedDb(RedisModuleCtx *ctx) { +int VM_GetSelectedDb(ValkeyModuleCtx *ctx) { return ctx->client->db->id; } @@ -3846,151 +3847,151 @@ int RM_GetSelectedDb(RedisModuleCtx *ctx) { * * Available flags and their meaning: * - * * REDISMODULE_CTX_FLAGS_LUA: The command is running in a Lua script + * * VALKEYMODULE_CTX_FLAGS_LUA: The command is running in a Lua script * - * * REDISMODULE_CTX_FLAGS_MULTI: The command is running inside a transaction + * * VALKEYMODULE_CTX_FLAGS_MULTI: The command is running inside a transaction * - * * REDISMODULE_CTX_FLAGS_REPLICATED: The command was sent over the replication + * * VALKEYMODULE_CTX_FLAGS_REPLICATED: The command was sent over the replication * link by the MASTER * - * * REDISMODULE_CTX_FLAGS_MASTER: The Redis instance is a master + * * VALKEYMODULE_CTX_FLAGS_PRIMARY: The Redis instance is a primary * - * * REDISMODULE_CTX_FLAGS_SLAVE: The Redis instance is a slave + * * VALKEYMODULE_CTX_FLAGS_REPLICA: The Redis instance is a replica * - * * REDISMODULE_CTX_FLAGS_READONLY: The Redis instance is read-only + * * VALKEYMODULE_CTX_FLAGS_READONLY: The Redis instance is read-only * - * * REDISMODULE_CTX_FLAGS_CLUSTER: The Redis instance is in cluster mode + * * VALKEYMODULE_CTX_FLAGS_CLUSTER: The Redis instance is in cluster mode * - * * REDISMODULE_CTX_FLAGS_AOF: The Redis instance has AOF enabled + * * VALKEYMODULE_CTX_FLAGS_AOF: The Redis instance has AOF enabled * - * * REDISMODULE_CTX_FLAGS_RDB: The instance has RDB enabled + * * VALKEYMODULE_CTX_FLAGS_RDB: The instance has RDB enabled * - * * REDISMODULE_CTX_FLAGS_MAXMEMORY: The instance has Maxmemory set + * * VALKEYMODULE_CTX_FLAGS_MAXMEMORY: The instance has Maxmemory set * - * * REDISMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction + * * VALKEYMODULE_CTX_FLAGS_EVICT: Maxmemory is set and has an eviction * policy that may delete keys * - * * REDISMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the + * * VALKEYMODULE_CTX_FLAGS_OOM: Redis is out of memory according to the * maxmemory setting. * - * * REDISMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before + * * VALKEYMODULE_CTX_FLAGS_OOM_WARNING: Less than 25% of memory remains before * reaching the maxmemory level. * - * * REDISMODULE_CTX_FLAGS_LOADING: Server is loading RDB/AOF + * * VALKEYMODULE_CTX_FLAGS_LOADING: Server is loading RDB/AOF * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE: No active link with the master. + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE: No active link with the master. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING: The replica is trying to + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING: The replica is trying to * connect with the master. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING: Master -> Replica RDB + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING: Master -> Replica RDB * transfer is in progress. * - * * REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE: The replica has an active link + * * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE: The replica has an active link * with its master. This is the * contrary of STALE state. * - * * REDISMODULE_CTX_FLAGS_ACTIVE_CHILD: There is currently some background + * * VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD: There is currently some background * process active (RDB, AUX or module). * - * * REDISMODULE_CTX_FLAGS_MULTI_DIRTY: The next EXEC will fail due to dirty + * * VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY: The next EXEC will fail due to dirty * CAS (touched keys). * - * * REDISMODULE_CTX_FLAGS_IS_CHILD: Redis is currently running inside + * * VALKEYMODULE_CTX_FLAGS_IS_CHILD: Redis is currently running inside * background child process. * - * * REDISMODULE_CTX_FLAGS_RESP3: Indicate the that client attached to this + * * VALKEYMODULE_CTX_FLAGS_RESP3: Indicate the that client attached to this * context is using RESP3. * - * * REDISMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting + * * VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP: The Redis instance is starting */ -int RM_GetContextFlags(RedisModuleCtx *ctx) { +int VM_GetContextFlags(ValkeyModuleCtx *ctx) { int flags = 0; /* Client specific flags */ if (ctx) { if (ctx->client) { if (ctx->client->flags & CLIENT_DENY_BLOCKING) - flags |= REDISMODULE_CTX_FLAGS_DENY_BLOCKING; + flags |= VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING; /* Module command received from MASTER, is replicated. */ if (ctx->client->flags & CLIENT_MASTER) - flags |= REDISMODULE_CTX_FLAGS_REPLICATED; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICATED; if (ctx->client->resp == 3) { - flags |= REDISMODULE_CTX_FLAGS_RESP3; + flags |= VALKEYMODULE_CTX_FLAGS_RESP3; } } /* For DIRTY flags, we need the blocked client if used */ client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client; if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) { - flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY; + flags |= VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY; } } if (scriptIsRunning()) - flags |= REDISMODULE_CTX_FLAGS_LUA; + flags |= VALKEYMODULE_CTX_FLAGS_LUA; if (server.in_exec) - flags |= REDISMODULE_CTX_FLAGS_MULTI; + flags |= VALKEYMODULE_CTX_FLAGS_MULTI; if (server.cluster_enabled) - flags |= REDISMODULE_CTX_FLAGS_CLUSTER; + flags |= VALKEYMODULE_CTX_FLAGS_CLUSTER; if (server.async_loading) - flags |= REDISMODULE_CTX_FLAGS_ASYNC_LOADING; + flags |= VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING; else if (server.loading) - flags |= REDISMODULE_CTX_FLAGS_LOADING; + flags |= VALKEYMODULE_CTX_FLAGS_LOADING; /* Maxmemory and eviction policy */ if (server.maxmemory > 0 && (!server.masterhost || !server.repl_slave_ignore_maxmemory)) { - flags |= REDISMODULE_CTX_FLAGS_MAXMEMORY; + flags |= VALKEYMODULE_CTX_FLAGS_MAXMEMORY; if (server.maxmemory_policy != MAXMEMORY_NO_EVICTION) - flags |= REDISMODULE_CTX_FLAGS_EVICT; + flags |= VALKEYMODULE_CTX_FLAGS_EVICT; } /* Persistence flags */ if (server.aof_state != AOF_OFF) - flags |= REDISMODULE_CTX_FLAGS_AOF; + flags |= VALKEYMODULE_CTX_FLAGS_AOF; if (server.saveparamslen > 0) - flags |= REDISMODULE_CTX_FLAGS_RDB; + flags |= VALKEYMODULE_CTX_FLAGS_RDB; /* Replication flags */ if (server.masterhost == NULL) { - flags |= REDISMODULE_CTX_FLAGS_MASTER; + flags |= VALKEYMODULE_CTX_FLAGS_PRIMARY; } else { - flags |= REDISMODULE_CTX_FLAGS_SLAVE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA; if (server.repl_slave_ro) - flags |= REDISMODULE_CTX_FLAGS_READONLY; + flags |= VALKEYMODULE_CTX_FLAGS_READONLY; /* Replica state flags. */ if (server.repl_state == REPL_STATE_CONNECT || server.repl_state == REPL_STATE_CONNECTING) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING; } else if (server.repl_state == REPL_STATE_TRANSFER) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING; } else if (server.repl_state == REPL_STATE_CONNECTED) { - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE; } if (server.repl_state != REPL_STATE_CONNECTED) - flags |= REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE; + flags |= VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE; } /* OOM flag. */ float level; int retval = getMaxmemoryState(NULL,NULL,NULL,&level); - if (retval == C_ERR) flags |= REDISMODULE_CTX_FLAGS_OOM; - if (level > 0.75) flags |= REDISMODULE_CTX_FLAGS_OOM_WARNING; + if (retval == C_ERR) flags |= VALKEYMODULE_CTX_FLAGS_OOM; + if (level > 0.75) flags |= VALKEYMODULE_CTX_FLAGS_OOM_WARNING; /* Presence of children processes. */ - if (hasActiveChildProcess()) flags |= REDISMODULE_CTX_FLAGS_ACTIVE_CHILD; - if (server.in_fork_child) flags |= REDISMODULE_CTX_FLAGS_IS_CHILD; + if (hasActiveChildProcess()) flags |= VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD; + if (server.in_fork_child) flags |= VALKEYMODULE_CTX_FLAGS_IS_CHILD; /* Non-empty server.loadmodule_queue means that Redis is starting. */ if (listLength(server.loadmodule_queue) > 0) - flags |= REDISMODULE_CTX_FLAGS_SERVER_STARTUP; + flags |= VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP; return flags; } @@ -4002,8 +4003,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 ValkeyModule_Call() with + * the "!" flag, or by calling ValkeyModule_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 @@ -4015,7 +4016,7 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { * garbage collection tasks, or that do writes and replicate such writes * periodically in timer callbacks or other periodic callbacks. */ -int RM_AvoidReplicaTraffic(void) { +int VM_AvoidReplicaTraffic(void) { return !!(isPausedActionsWithUpdate(PAUSE_ACTION_REPLICA)); } @@ -4027,26 +4028,26 @@ 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 ValkeyModule_GetSelectedDb() * before in order to restore the old DB number before returning. */ -int RM_SelectDb(RedisModuleCtx *ctx, int newid) { +int VM_SelectDb(ValkeyModuleCtx *ctx, int newid) { int retval = selectDb(ctx->client,newid); - return (retval == C_OK) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == C_OK) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } /* Check if a key exists, without affecting its last access time. * - * This is equivalent to calling RM_OpenKey with the mode REDISMODULE_READ | - * REDISMODULE_OPEN_KEY_NOTOUCH, then checking if NULL was returned and, if not, - * calling RM_CloseKey on the opened key. + * This is equivalent to calling VM_OpenKey with the mode VALKEYMODULE_READ | + * VALKEYMODULE_OPEN_KEY_NOTOUCH, then checking if NULL was returned and, if not, + * calling VM_CloseKey on the opened key. */ -int RM_KeyExists(RedisModuleCtx *ctx, robj *keyname) { +int VM_KeyExists(ValkeyModuleCtx *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 ValkeyModuleKey struct */ +static void moduleInitKey(ValkeyModuleKey *kp, ValkeyModuleCtx *ctx, robj *keyname, robj *value, int mode){ kp->ctx = ctx; kp->db = ctx->client->db; kp->key = keyname; @@ -4058,7 +4059,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(ValkeyModuleKey *key) { switch (key->value->type) { case OBJ_ZSET: zsetKeyReset(key); break; case OBJ_STREAM: key->u.stream.signalready = 0; break; @@ -4070,33 +4071,33 @@ static void moduleInitKeyTypeSpecific(RedisModuleKey *key) { * operations on the key. * * The return value is the handle representing the key, that must be - * closed with RM_CloseKey(). + * closed with VM_CloseKey(). * - * If the key does not exist and REDISMODULE_WRITE mode is requested, the handle + * If the key does not exist and VALKEYMODULE_WRITE mode is requested, the handle * is still returned, since it is possible to perform operations on * 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 + * a list push operation). If the mode is just VALKEYMODULE_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 ValkeyModule_CloseKey() and ValkeyModule_KeyType() on a NULL * value. * * Extra flags that can be pass to the API under the mode argument: - * * REDISMODULE_OPEN_KEY_NOTOUCH - Avoid touching the LRU/LFU of the key when opened. - * * REDISMODULE_OPEN_KEY_NONOTIFY - Don't trigger keyspace event on key misses. - * * 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; + * * VALKEYMODULE_OPEN_KEY_NOTOUCH - Avoid touching the LRU/LFU of the key when opened. + * * VALKEYMODULE_OPEN_KEY_NONOTIFY - Don't trigger keyspace event on key misses. + * * VALKEYMODULE_OPEN_KEY_NOSTATS - Don't update keyspace hits/misses counters. + * * VALKEYMODULE_OPEN_KEY_NOEXPIRE - Avoid deleting lazy expired keys. + * * VALKEYMODULE_OPEN_KEY_NOEFFECTS - Avoid any effects from fetching the key. */ +ValkeyModuleKey *VM_OpenKey(ValkeyModuleCtx *ctx, robj *keyname, int mode) { + ValkeyModuleKey *kp; robj *value; int flags = 0; - flags |= (mode & REDISMODULE_OPEN_KEY_NOTOUCH? LOOKUP_NOTOUCH: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NONOTIFY? LOOKUP_NONOTIFY: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOSTATS? LOOKUP_NOSTATS: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOEXPIRE? LOOKUP_NOEXPIRE: 0); - flags |= (mode & REDISMODULE_OPEN_KEY_NOEFFECTS? LOOKUP_NOEFFECTS: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOTOUCH? LOOKUP_NOTOUCH: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NONOTIFY? LOOKUP_NONOTIFY: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOSTATS? LOOKUP_NOSTATS: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOEXPIRE? LOOKUP_NOEXPIRE: 0); + flags |= (mode & VALKEYMODULE_OPEN_KEY_NOEFFECTS? LOOKUP_NOEFFECTS: 0); - if (mode & REDISMODULE_WRITE) { + if (mode & VALKEYMODULE_WRITE) { value = lookupKeyWriteWithFlags(ctx->client->db,keyname, flags); } else { value = lookupKeyReadWithFlags(ctx->client->db,keyname, flags); @@ -4108,7 +4109,7 @@ RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { /* Setup the key handle. */ kp = zmalloc(sizeof(*kp)); moduleInitKey(kp, ctx, keyname, value, mode); - autoMemoryAdd(ctx,REDISMODULE_AM_KEY,kp); + autoMemoryAdd(ctx,VALKEYMODULE_AM_KEY,kp); return kp; } @@ -4118,31 +4119,31 @@ RedisModuleKey *RM_OpenKey(RedisModuleCtx *ctx, robj *keyname, int mode) { * by the redis server version in use. * Example: * - * int supportedMode = RM_GetOpenKeyModesAll(); - * if (supportedMode & REDISMODULE_OPEN_KEY_NOTOUCH) { - * // REDISMODULE_OPEN_KEY_NOTOUCH is supported + * int supportedMode = VM_GetOpenKeyModesAll(); + * if (supportedMode & VALKEYMODULE_OPEN_KEY_NOTOUCH) { + * // VALKEYMODULE_OPEN_KEY_NOTOUCH is supported * } else{ - * // REDISMODULE_OPEN_KEY_NOTOUCH is not supported + * // VALKEYMODULE_OPEN_KEY_NOTOUCH is not supported * } */ -int RM_GetOpenKeyModesAll(void) { - return _REDISMODULE_OPEN_KEY_ALL; +int VM_GetOpenKeyModesAll(void) { + return _VALKEYMODULE_OPEN_KEY_ALL; } -/* Destroy a RedisModuleKey struct (freeing is the responsibility of the caller). */ -static void moduleCloseKey(RedisModuleKey *key) { +/* Destroy a ValkeyModuleKey struct (freeing is the responsibility of the caller). */ +static void moduleCloseKey(ValkeyModuleKey *key) { int signal = SHOULD_SIGNAL_MODIFIED_KEYS(key->ctx); - if ((key->mode & REDISMODULE_WRITE) && signal) + if ((key->mode & VALKEYMODULE_WRITE) && signal) signalModifiedKey(key->ctx->client,key->db,key->key); if (key->value) { if (key->iter) moduleFreeKeyIterator(key); switch (key->value->type) { case OBJ_ZSET: - RM_ZsetRangeStop(key); + VM_ZsetRangeStop(key); break; case OBJ_STREAM: if (key->u.stream.signalready) - /* One or more RM_StreamAdd() have been done. */ + /* One or more VM_StreamAdd() have been done. */ signalKeyAsReady(key->db, key->key, OBJ_STREAM); break; } @@ -4152,28 +4153,28 @@ static void moduleCloseKey(RedisModuleKey *key) { } /* Close a key handle. */ -void RM_CloseKey(RedisModuleKey *key) { +void VM_CloseKey(ValkeyModuleKey *key) { if (key == NULL) return; moduleCloseKey(key); - autoMemoryFreed(key->ctx,REDISMODULE_AM_KEY,key); + autoMemoryFreed(key->ctx,VALKEYMODULE_AM_KEY,key); zfree(key); } /* Return the type of the key. If the key pointer is NULL then - * REDISMODULE_KEYTYPE_EMPTY is returned. */ -int RM_KeyType(RedisModuleKey *key) { - if (key == NULL || key->value == NULL) return REDISMODULE_KEYTYPE_EMPTY; + * VALKEYMODULE_KEYTYPE_EMPTY is returned. */ +int VM_KeyType(ValkeyModuleKey *key) { + if (key == NULL || key->value == NULL) return VALKEYMODULE_KEYTYPE_EMPTY; /* We map between defines so that we are free to change the internal * defines as desired. */ switch(key->value->type) { - case OBJ_STRING: return REDISMODULE_KEYTYPE_STRING; - case OBJ_LIST: return REDISMODULE_KEYTYPE_LIST; - case OBJ_SET: return REDISMODULE_KEYTYPE_SET; - case OBJ_ZSET: return REDISMODULE_KEYTYPE_ZSET; - case OBJ_HASH: return REDISMODULE_KEYTYPE_HASH; - case OBJ_MODULE: return REDISMODULE_KEYTYPE_MODULE; - case OBJ_STREAM: return REDISMODULE_KEYTYPE_STREAM; - default: return REDISMODULE_KEYTYPE_EMPTY; + case OBJ_STRING: return VALKEYMODULE_KEYTYPE_STRING; + case OBJ_LIST: return VALKEYMODULE_KEYTYPE_LIST; + case OBJ_SET: return VALKEYMODULE_KEYTYPE_SET; + case OBJ_ZSET: return VALKEYMODULE_KEYTYPE_ZSET; + case OBJ_HASH: return VALKEYMODULE_KEYTYPE_HASH; + case OBJ_MODULE: return VALKEYMODULE_KEYTYPE_MODULE; + case OBJ_STREAM: return VALKEYMODULE_KEYTYPE_STREAM; + default: return VALKEYMODULE_KEYTYPE_EMPTY; } } @@ -4182,7 +4183,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 VM_ValueLength(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL) return 0; switch(key->value->type) { case OBJ_STRING: return stringObjectLen(key->value); @@ -4197,150 +4198,150 @@ size_t RM_ValueLength(RedisModuleKey *key) { /* If the key is open for writing, remove it, and setup the key to * 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) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing VALKEYMODULE_ERR is returned. */ +int VM_DeleteKey(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; if (key->value) { dbDelete(key->db,key->key); key->value = NULL; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* If the key is open for writing, unlink it (that is delete it in a * non-blocking way, not reclaiming memory immediately) and setup the key to * 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) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing VALKEYMODULE_ERR is returned. */ +int VM_UnlinkKey(ValkeyModuleKey *key) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; if (key->value) { dbAsyncDelete(key->db,key->key); key->value = NULL; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { + * VALKEYMODULE_NO_EXPIRE is returned. */ +mstime_t VM_GetExpire(ValkeyModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) - return REDISMODULE_NO_EXPIRE; + return VALKEYMODULE_NO_EXPIRE; expire -= commandTimeSnapshot(); return expire >= 0 ? expire : 0; } /* Set a new expire for the key. If the special expire - * REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was + * VALKEYMODULE_NO_EXPIRE is set, the expire is cancelled if there was * one (the same as the PERSIST command). * * Note that the expire must be provided as a positive integer representing * the number of milliseconds of TTL the key should have. * - * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetExpire(RedisModuleKey *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) { +int VM_SetExpire(ValkeyModuleKey *key, mstime_t expire) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != VALKEYMODULE_NO_EXPIRE)) + return VALKEYMODULE_ERR; + if (expire != VALKEYMODULE_NO_EXPIRE) { expire += commandTimeSnapshot(); setExpire(key->ctx->client,key->db,key->key,expire); } else { removeExpire(key->db,key->key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { + * VALKEYMODULE_NO_EXPIRE is returned. */ +mstime_t VM_GetAbsExpire(ValkeyModuleKey *key) { mstime_t expire = getExpire(key->db,key->key); if (expire == -1 || key->value == NULL) - return REDISMODULE_NO_EXPIRE; + return VALKEYMODULE_NO_EXPIRE; return expire; } /* Set a new expire for the key. If the special expire - * REDISMODULE_NO_EXPIRE is set, the expire is cancelled if there was + * VALKEYMODULE_NO_EXPIRE is set, the expire is cancelled if there was * one (the same as the PERSIST command). * * Note that the expire must be provided as a positive integer representing * the absolute Unix timestamp the key should have. * - * The function returns REDISMODULE_OK on success or REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success or VALKEYMODULE_ERR if * the key was not open for writing or is an empty key. */ -int RM_SetAbsExpire(RedisModuleKey *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) { +int VM_SetAbsExpire(ValkeyModuleKey *key, mstime_t expire) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->value == NULL || (expire < 0 && expire != VALKEYMODULE_NO_EXPIRE)) + return VALKEYMODULE_ERR; + if (expire != VALKEYMODULE_NO_EXPIRE) { setExpire(key->ctx->client,key->db,key->key,expire); } else { removeExpire(key->db,key->key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Performs similar operation to FLUSHALL, and optionally start a new AOF file (if enabled) * If restart_aof is true, you must make sure the command that triggered this call is not * propagated to the AOF file. * When async is set to true, db contents will be freed by a background thread. */ -void RM_ResetDataset(int restart_aof, int async) { +void VM_ResetDataset(int restart_aof, int async) { if (restart_aof && server.aof_state != AOF_OFF) stopAppendOnly(); flushAllDataAndResetRDB((async? EMPTYDB_ASYNC: EMPTYDB_NO_FLAGS) | EMPTYDB_NOFUNCTIONS); if (server.aof_enabled && restart_aof) restartAOFAfterSYNC(); } /* Returns the number of keys in the current db. */ -unsigned long long RM_DbSize(RedisModuleCtx *ctx) { +unsigned long long VM_DbSize(ValkeyModuleCtx *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) { +ValkeyModuleString *VM_RandomKey(ValkeyModuleCtx *ctx) { robj *key = dbRandomKey(ctx->client->db); - autoMemoryAdd(ctx,REDISMODULE_AM_STRING,key); + autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,key); return key; } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const ValkeyModuleString *VM_GetKeyNameFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->from_key; } /* Returns the name of the target key currently being processed. */ -const RedisModuleString *RM_GetToKeyNameFromOptCtx(RedisModuleKeyOptCtx *ctx) { +const ValkeyModuleString *VM_GetToKeyNameFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->to_key; } /* Returns the dbid currently being processed. */ -int RM_GetDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int VM_GetDbIdFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->from_dbid; } /* Returns the target dbid currently being processed. */ -int RM_GetToDbIdFromOptCtx(RedisModuleKeyOptCtx *ctx) { +int VM_GetToDbIdFromOptCtx(ValkeyModuleKeyOptCtx *ctx) { return ctx->to_dbid; } /* -------------------------------------------------------------------------- * ## Key API for String type * - * See also RM_ValueLength(), which returns the length of a string. + * See also VM_ValueLength(), which returns the length of a string. * -------------------------------------------------------------------------- */ /* If the key is open for writing, set the specified string 'str' 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_StringSet(RedisModuleKey *key, RedisModuleString *str) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; - RM_DeleteKey(key); + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing or there is an active iterator, VALKEYMODULE_ERR is returned. */ +int VM_StringSet(ValkeyModuleKey *key, ValkeyModuleString *str) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) return VALKEYMODULE_ERR; + VM_DeleteKey(key); setKey(key->ctx->client,key->db,key->key,str,SETKEY_NO_SIGNAL); key->value = str; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Prepare the key associated string value for DMA access, and returns @@ -4349,8 +4350,8 @@ int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { * * The 'mode' is composed by bitwise OR-ing the following flags: * - * REDISMODULE_READ -- Read access - * REDISMODULE_WRITE -- Write access + * VALKEYMODULE_READ -- Read access + * VALKEYMODULE_WRITE -- Write access * * If the DMA is not requested for writing, the pointer returned should * only be accessed in a read-only fashion. @@ -4363,16 +4364,16 @@ int RM_StringSet(RedisModuleKey *key, RedisModuleString *str) { * the pointer is obtained, for all the time we want to use DMA access * to read or modify the string. * - * 2. Each time RM_StringTruncate() is called, to continue with the DMA - * access, RM_StringDMA() should be called again to re-obtain + * 2. Each time VM_StringTruncate() is called, to continue with the DMA + * access, VM_StringDMA() should be called again to re-obtain * a new pointer and length. * * 3. If the returned pointer is not NULL, but the length is zero, no * byte can be touched (the string is empty, or the key itself is empty) - * so a RM_StringTruncate() call should be used if there is to enlarge + * so a VM_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 *VM_StringDMA(ValkeyModuleKey *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 @@ -4387,7 +4388,7 @@ char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { /* For write access, and even for read access if the object is encoded, * we unshare the string (that has the side effect of decoding it). */ - if ((mode & REDISMODULE_WRITE) || key->value->encoding != OBJ_ENCODING_RAW) + if ((mode & VALKEYMODULE_WRITE) || key->value->encoding != OBJ_ENCODING_RAW) key->value = dbUnshareStringValue(key->db, key->key, key->value); *len = sdslen(key->value->ptr); @@ -4397,23 +4398,23 @@ char *RM_StringDMA(RedisModuleKey *key, size_t *len, int mode) { /* If the key is open for writing and is of string type, resize it, padding * with zero bytes if the new length is greater than the old one. * - * After this call, RM_StringDMA() must be called again to continue + * After this call, VM_StringDMA() must be called again to continue * DMA access with the new pointer. * - * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR on + * The function returns VALKEYMODULE_OK on success, and VALKEYMODULE_ERR on * error, that is, the key is not open for writing, is not a string * or resizing for more than 512 MB is requested. * * 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) { - 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; +int VM_StringTruncate(ValkeyModuleKey *key, size_t newlen) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_STRING) return VALKEYMODULE_ERR; + if (newlen > 512*1024*1024) return VALKEYMODULE_ERR; - /* Empty key and new len set to 0. Just return REDISMODULE_OK without + /* Empty key and new len set to 0. Just return VALKEYMODULE_OK without * doing anything. */ - if (key->value == NULL && newlen == 0) return REDISMODULE_OK; + if (key->value == NULL && newlen == 0) return VALKEYMODULE_OK; if (key->value == NULL) { /* Empty key: create it with the new size. */ @@ -4434,7 +4435,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { key->value->ptr = sdsRemoveFreeSpace(key->value->ptr, 0); } } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -4448,28 +4449,28 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { * * This enables iteration to be done efficiently using a simple for loop: * - * long n = RM_ValueLength(key); + * long n = VM_ValueLength(key); * for (long i = 0; i < n; i++) { - * RedisModuleString *elem = RedisModule_ListGet(key, i); + * ValkeyModuleString *elem = ValkeyModule_ListGet(key, i); * // Do stuff... * } * - * Note that after modifying a list using RM_ListPop, RM_ListSet or - * RM_ListInsert, the internal iterator is invalidated so the next operation + * Note that after modifying a list using VM_ListPop, VM_ListSet or + * VM_ListInsert, the internal iterator is invalidated so the next operation * will require a linear seek. * - * Modifying a list in any another way, for example using RM_Call(), while a key + * Modifying a list in any another way, for example using VM_Call(), while a key * is open will confuse the internal iterator and may cause trouble if the key * is used after such modifications. The key must be reopened in this case. * - * See also RM_ValueLength(), which returns the length of a list. + * See also VM_ValueLength(), which returns the length of a list. * -------------------------------------------------------------------------- */ /* Seeks the key's internal list iterator to the given index. On success, 1 is * 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(ValkeyModuleKey *key, long index, int mode) { if (!key) { errno = EINVAL; return 0; @@ -4514,9 +4515,9 @@ int moduleListIteratorSeek(RedisModuleKey *key, long index, int mode) { } /* Push an element into a list, on head or tail depending on 'where' argument - * (REDISMODULE_LIST_HEAD or REDISMODULE_LIST_TAIL). If the key refers to an - * empty key opened for writing, the key is created. On success, REDISMODULE_OK - * is returned. On failure, REDISMODULE_ERR is returned and `errno` is set as + * (VALKEYMODULE_LIST_HEAD or VALKEYMODULE_LIST_TAIL). If the key refers to an + * empty key opened for writing, the key is created. On success, VALKEYMODULE_OK + * is returned. On failure, VALKEYMODULE_ERR is returned and `errno` is set as * follows: * * - EINVAL if key or ele is NULL. @@ -4524,33 +4525,33 @@ 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 VM_ListPush(ValkeyModuleKey *key, int where, ValkeyModuleString *ele) { if (!key || !ele) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->value != NULL && key->value->type != OBJ_LIST) { errno = ENOTSUP; - return REDISMODULE_ERR; - } if (!(key->mode & REDISMODULE_WRITE)) { + return VALKEYMODULE_ERR; + } if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR; + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_LIST) return VALKEYMODULE_ERR; if (key->iter) moduleFreeKeyIterator(key); - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST); + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_LIST); listTypeTryConversionAppend(key->value, &ele, 0, 0, moduleFreeListIterator, key); listTypePush(key->value, ele, - (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); - return REDISMODULE_OK; + (where == VALKEYMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); + return VALKEYMODULE_OK; } /* Pop an element from the list, and returns it as a module string object - * that the user should be free with RM_FreeString() or by enabling + * that the user should be free with VM_FreeString() or by enabling * automatic memory. The `where` argument specifies if the element should be - * popped from the beginning or the end of the list (REDISMODULE_LIST_HEAD or - * REDISMODULE_LIST_TAIL). On failure, the command returns NULL and sets + * popped from the beginning or the end of the list (VALKEYMODULE_LIST_HEAD or + * VALKEYMODULE_LIST_TAIL). On failure, the command returns NULL and sets * `errno` as follows: * * - EINVAL if key is NULL. @@ -4558,30 +4559,30 @@ 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) { +ValkeyModuleString *VM_ListPop(ValkeyModuleKey *key, int where) { if (!key) { errno = EINVAL; return NULL; } else if (key->value == NULL || key->value->type != OBJ_LIST) { errno = ENOTSUP; return NULL; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return NULL; } if (key->iter) moduleFreeKeyIterator(key); robj *ele = listTypePop(key->value, - (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); + (where == VALKEYMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL); robj *decoded = getDecodedObject(ele); decrRefCount(ele); if (!moduleDelKeyIfEmpty(key)) listTypeTryConversion(key->value, LIST_CONV_SHRINKING, moduleFreeListIterator, key); - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,decoded); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,decoded); return decoded; } /* Returns the element at index `index` in the list stored at `key`, like the - * LINDEX command. The element should be free'd using RM_FreeString() or using + * LINDEX command. The element should be free'd using VM_FreeString() or using * automatic memory management. * * The index is zero-based, so 0 means the first element, 1 the second element @@ -4597,12 +4598,12 @@ 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) { - if (moduleListIteratorSeek(key, index, REDISMODULE_READ)) { +ValkeyModuleString *VM_ListGet(ValkeyModuleKey *key, long index) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_READ)) { robj *elem = listTypeGet(&key->u.list.entry); robj *decoded = getDecodedObject(elem); decrRefCount(elem); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, decoded); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, decoded); return decoded; } else { return NULL; @@ -4616,7 +4617,7 @@ RedisModuleString *RM_ListGet(RedisModuleKey *key, long index) { * tail of the list. Here, -1 means the last element, -2 means the penultimate * and so forth. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4624,24 +4625,24 @@ 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 VM_ListSet(ValkeyModuleKey *key, long index, ValkeyModuleString *value) { if (!value) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (!key->value || key->value->type != OBJ_LIST) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } listTypeTryConversionAppend(key->value, &value, 0, 0, moduleFreeListIterator, key); - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { listTypeReplace(&key->u.list.entry, value); /* A note in quicklist.c forbids use of iterator after insert, so * probably also after replace. */ moduleFreeKeyIterator(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } @@ -4652,7 +4653,7 @@ int RM_ListSet(RedisModuleKey *key, long index, RedisModuleString *value) { * tail of the list. Here, -1 means the last element, -2 means the penultimate * and so forth. The index is the element's index after inserting it. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4660,41 +4661,41 @@ 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 VM_ListInsert(ValkeyModuleKey *key, long index, ValkeyModuleString *value) { if (!value) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key != NULL && key->value == NULL && (index == 0 || index == -1)) { /* Insert in empty key => push. */ - return RM_ListPush(key, REDISMODULE_LIST_TAIL, value); + return VM_ListPush(key, VALKEYMODULE_LIST_TAIL, value); } else if (key != NULL && key->value != NULL && key->value->type == OBJ_LIST && (index == (long)listTypeLength(key->value) || index == -1)) { /* Insert after the last element => push tail. */ - return RM_ListPush(key, REDISMODULE_LIST_TAIL, value); + return VM_ListPush(key, VALKEYMODULE_LIST_TAIL, value); } else if (key != NULL && key->value != NULL && key->value->type == OBJ_LIST && (index == 0 || index == -(long)listTypeLength(key->value) - 1)) { /* Insert before the first element => push head. */ - return RM_ListPush(key, REDISMODULE_LIST_HEAD, value); + return VM_ListPush(key, VALKEYMODULE_LIST_HEAD, value); } listTypeTryConversionAppend(key->value, &value, 0, 0, moduleFreeListIterator, key); - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { int where = index < 0 ? LIST_TAIL : LIST_HEAD; listTypeInsert(&key->u.list.entry, value, where); /* A note in quicklist.c forbids use of iterator after insert. */ moduleFreeKeyIterator(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Removes an element at the given index. The index is 0-based. A negative index * can also be used, counting from the end of the list. * - * On success, REDISMODULE_OK is returned. On failure, REDISMODULE_ERR is + * On success, VALKEYMODULE_OK is returned. On failure, VALKEYMODULE_ERR is * returned and `errno` is set as follows: * * - EINVAL if key or value is NULL. @@ -4702,12 +4703,12 @@ 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) { - if (moduleListIteratorSeek(key, index, REDISMODULE_WRITE)) { +int VM_ListDelete(ValkeyModuleKey *key, long index) { + if (moduleListIteratorSeek(key, index, VALKEYMODULE_WRITE)) { listTypeDelete(key->iter, &key->u.list.entry); - if (moduleDelKeyIfEmpty(key)) return REDISMODULE_OK; + if (moduleDelKeyIfEmpty(key)) return VALKEYMODULE_OK; listTypeTryConversion(key->value, LIST_CONV_SHRINKING, moduleFreeListIterator, key); - if (!key->iter) return REDISMODULE_OK; /* Return ASAP if iterator has been freed */ + if (!key->iter) return VALKEYMODULE_OK; /* Return ASAP if iterator has been freed */ if (listTypeNext(key->iter, &key->u.list.entry)) { /* After delete entry at position 'index', we need to update * 'key->u.list.index' according to the following cases: @@ -4725,35 +4726,35 @@ int RM_ListDelete(RedisModuleKey *key, long index) { /* Reset list iterator if the next entry doesn't exist. */ moduleFreeKeyIterator(key); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* -------------------------------------------------------------------------- * ## Key API for Sorted Set type * - * See also RM_ValueLength(), which returns the length of a sorted set. + * See also VM_ValueLength(), which returns the length of a sorted set. * -------------------------------------------------------------------------- */ /* Conversion from/to public flags of the Modules API and our private flags, * so that we have everything decoupled. */ int moduleZsetAddFlagsToCoreFlags(int flags) { int retflags = 0; - if (flags & REDISMODULE_ZADD_XX) retflags |= ZADD_IN_XX; - if (flags & REDISMODULE_ZADD_NX) retflags |= ZADD_IN_NX; - if (flags & REDISMODULE_ZADD_GT) retflags |= ZADD_IN_GT; - if (flags & REDISMODULE_ZADD_LT) retflags |= ZADD_IN_LT; + if (flags & VALKEYMODULE_ZADD_XX) retflags |= ZADD_IN_XX; + if (flags & VALKEYMODULE_ZADD_NX) retflags |= ZADD_IN_NX; + if (flags & VALKEYMODULE_ZADD_GT) retflags |= ZADD_IN_GT; + if (flags & VALKEYMODULE_ZADD_LT) retflags |= ZADD_IN_LT; return retflags; } /* See previous function comment. */ int moduleZsetAddFlagsFromCoreFlags(int flags) { int retflags = 0; - if (flags & ZADD_OUT_ADDED) retflags |= REDISMODULE_ZADD_ADDED; - if (flags & ZADD_OUT_UPDATED) retflags |= REDISMODULE_ZADD_UPDATED; - if (flags & ZADD_OUT_NOP) retflags |= REDISMODULE_ZADD_NOP; + if (flags & ZADD_OUT_ADDED) retflags |= VALKEYMODULE_ZADD_ADDED; + if (flags & ZADD_OUT_UPDATED) retflags |= VALKEYMODULE_ZADD_UPDATED; + if (flags & ZADD_OUT_NOP) retflags |= VALKEYMODULE_ZADD_NOP; return retflags; } @@ -4769,72 +4770,72 @@ int moduleZsetAddFlagsFromCoreFlags(int flags) { * * The input flags are: * - * REDISMODULE_ZADD_XX: Element must already exist. Do nothing otherwise. - * REDISMODULE_ZADD_NX: Element must not exist. Do nothing otherwise. - * REDISMODULE_ZADD_GT: If element exists, new score must be greater than the current score. + * VALKEYMODULE_ZADD_XX: Element must already exist. Do nothing otherwise. + * VALKEYMODULE_ZADD_NX: Element must not exist. Do nothing otherwise. + * VALKEYMODULE_ZADD_GT: If element exists, new score must be greater than the current score. * Do nothing otherwise. Can optionally be combined with XX. - * REDISMODULE_ZADD_LT: If element exists, new score must be less than the current score. + * VALKEYMODULE_ZADD_LT: If element exists, new score must be less than the current score. * Do nothing otherwise. Can optionally be combined with XX. * * The output flags are: * - * REDISMODULE_ZADD_ADDED: The new element was added to the sorted set. - * REDISMODULE_ZADD_UPDATED: The score of the element was updated. - * REDISMODULE_ZADD_NOP: No operation was performed because XX or NX flags. + * VALKEYMODULE_ZADD_ADDED: The new element was added to the sorted set. + * VALKEYMODULE_ZADD_UPDATED: The score of the element was updated. + * VALKEYMODULE_ZADD_NOP: No operation was performed because XX or NX flags. * - * On success the function returns REDISMODULE_OK. On the following errors - * REDISMODULE_ERR is returned: + * On success the function returns VALKEYMODULE_OK. On the following errors + * VALKEYMODULE_ERR is returned: * * * The key was not opened for writing. * * 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 VM_ZsetAdd(ValkeyModuleKey *key, double score, ValkeyModuleString *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; - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_ZSET); if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); if (zsetAdd(key->value,score,ele->ptr,in_flags,&out_flags,NULL) == 0) { if (flagsptr) *flagsptr = 0; moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* This function works exactly like RM_ZsetAdd(), but instead of setting +/* This function works exactly like VM_ZsetAdd(), but instead of setting * a new score, the score of the existing element is incremented, or if the * element does not already exist, it is added assuming the old score was * zero. * * The input and output flags, and the return value, have the same exact * meaning, with the only difference that this function will return - * REDISMODULE_ERR even when 'score' is a valid double number, but adding it + * VALKEYMODULE_ERR even when 'score' is a valid double number, but adding it * to the existing score results into a NaN (not a number) condition. * * 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 VM_ZsetIncrby(ValkeyModuleKey *key, double score, ValkeyModuleString *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; - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_ZSET); + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_ZSET); if (flagsptr) in_flags = moduleZsetAddFlagsToCoreFlags(*flagsptr); in_flags |= ZADD_IN_INCR; if (zsetAdd(key->value,score,ele->ptr,in_flags,&out_flags,newscore) == 0) { if (flagsptr) *flagsptr = 0; moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (flagsptr) *flagsptr = moduleZsetAddFlagsFromCoreFlags(out_flags); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Remove the specified element from the sorted set. - * The function returns REDISMODULE_OK on success, and REDISMODULE_ERR + * The function returns VALKEYMODULE_OK on success, and VALKEYMODULE_ERR * on one of the following conditions: * * * The key was not opened for writing. @@ -4851,48 +4852,48 @@ 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) { - if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR; - if (key->value && key->value->type != OBJ_ZSET) return REDISMODULE_ERR; +int VM_ZsetRem(ValkeyModuleKey *key, ValkeyModuleString *ele, int *deleted) { + if (!(key->mode & VALKEYMODULE_WRITE)) return VALKEYMODULE_ERR; + if (key->value && key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; if (key->value != NULL && zsetDel(key->value,ele->ptr)) { if (deleted) *deleted = 1; moduleDelKeyIfEmpty(key); } else { if (deleted) *deleted = 0; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* On success retrieve the double score associated at the sorted set element - * 'ele' and returns REDISMODULE_OK. Otherwise REDISMODULE_ERR is returned + * 'ele' and returns VALKEYMODULE_OK. Otherwise VALKEYMODULE_ERR is returned * to signal one of the following conditions: * * * There is no such element 'ele' in the sorted set. * * The key is not a sorted set. * * The key is an open empty key. */ -int RM_ZsetScore(RedisModuleKey *key, RedisModuleString *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; - return REDISMODULE_OK; +int VM_ZsetScore(ValkeyModuleKey *key, ValkeyModuleString *ele, double *score) { + if (key->value == NULL) return VALKEYMODULE_ERR; + if (key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; + if (zsetScore(key->value,ele->ptr,score) == C_ERR) return VALKEYMODULE_ERR; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- * ## Key API for Sorted Set iterator * -------------------------------------------------------------------------- */ -void zsetKeyReset(RedisModuleKey *key) { - key->u.zset.type = REDISMODULE_ZSET_RANGE_NONE; +void zsetKeyReset(ValkeyModuleKey *key) { + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_NONE; key->u.zset.current = NULL; key->u.zset.er = 1; } /* Stop a sorted set iteration. */ -void RM_ZsetRangeStop(RedisModuleKey *key) { +void VM_ZsetRangeStop(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return; /* Free resources if needed. */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) zslFreeLexRange(&key->u.zset.lrs); /* Setup sensible values so that misused iteration API calls when an * iterator is not active will result into something more sensible @@ -4901,22 +4902,22 @@ 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 VM_ZsetRangeEndReached(ValkeyModuleKey *key) { if (!key->value || key->value->type != OBJ_ZSET) return 1; return key->u.zset.er; } -/* Helper function for RM_ZsetFirstInScoreRange() and RM_ZsetLastInScoreRange(). +/* Helper function for VM_ZsetFirstInScoreRange() and VM_ZsetLastInScoreRange(). * Setup the sorted set iteration according to the specified score range * (see the functions calling it for more info). If 'first' is true the * 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) { - if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; + * otherwise the last. Return VALKEYMODULE_OK on success otherwise + * VALKEYMODULE_ERR. */ +int zsetInitScoreRange(ValkeyModuleKey *key, double min, double max, int minex, int maxex, int first) { + if (!key->value || key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; - RM_ZsetRangeStop(key); - key->u.zset.type = REDISMODULE_ZSET_RANGE_SCORE; + VM_ZsetRangeStop(key); + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_SCORE; key->u.zset.er = 0; /* Setup the range structure used by the sorted set core implementation @@ -4939,57 +4940,57 @@ int zsetInitScoreRange(RedisModuleKey *key, double min, double max, int minex, i serverPanic("Unsupported zset encoding"); } if (key->u.zset.current == NULL) key->u.zset.er = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Setup a sorted set iterator seeking the first element in the specified - * range. Returns REDISMODULE_OK if the iterator was correctly initialized - * otherwise REDISMODULE_ERR is returned in the following conditions: + * range. Returns VALKEYMODULE_OK if the iterator was correctly initialized + * otherwise VALKEYMODULE_ERR is returned in the following conditions: * * 1. The value stored at key is not a sorted set or the key is empty. * * The range is specified according to the two double values 'min' and 'max'. * Both can be infinite using the following two macros: * - * * REDISMODULE_POSITIVE_INFINITE for positive infinite value - * * REDISMODULE_NEGATIVE_INFINITE for negative infinite value + * * VALKEYMODULE_POSITIVE_INFINITE for positive infinite value + * * VALKEYMODULE_NEGATIVE_INFINITE for negative infinite value * * '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 VM_ZsetFirstInScoreRange(ValkeyModuleKey *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 ValkeyModule_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 VM_ZsetLastInScoreRange(ValkeyModuleKey *key, double min, double max, int minex, int maxex) { return zsetInitScoreRange(key,min,max,minex,maxex,0); } -/* Helper function for RM_ZsetFirstInLexRange() and RM_ZsetLastInLexRange(). +/* Helper function for VM_ZsetFirstInLexRange() and VM_ZsetLastInLexRange(). * Setup the sorted set iteration according to the specified lexicographical * range (see the functions calling it for more info). If 'first' is true the * 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. + * otherwise the last. Return VALKEYMODULE_OK on success otherwise + * VALKEYMODULE_ERR. * * 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) { - if (!key->value || key->value->type != OBJ_ZSET) return REDISMODULE_ERR; +int zsetInitLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max, int first) { + if (!key->value || key->value->type != OBJ_ZSET) return VALKEYMODULE_ERR; - RM_ZsetRangeStop(key); + VM_ZsetRangeStop(key); key->u.zset.er = 0; /* Setup the range structure used by the sorted set core implementation * in order to seek at the specified element. */ zlexrangespec *zlrs = &key->u.zset.lrs; - if (zslParseLexRange(min, max, zlrs) == C_ERR) return REDISMODULE_ERR; + if (zslParseLexRange(min, max, zlrs) == C_ERR) return VALKEYMODULE_ERR; /* Set the range type to lex only after successfully parsing the range, * otherwise we don't want the zlexrangespec to be freed. */ - key->u.zset.type = REDISMODULE_ZSET_RANGE_LEX; + key->u.zset.type = VALKEYMODULE_ZSET_RANGE_LEX; if (key->value->encoding == OBJ_ENCODING_LISTPACK) { key->u.zset.current = first ? zzlFirstInLexRange(key->value->ptr,zlrs) : @@ -5004,36 +5005,36 @@ int zsetInitLexRange(RedisModuleKey *key, RedisModuleString *min, RedisModuleStr } if (key->u.zset.current == NULL) key->u.zset.er = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Setup a sorted set iterator seeking the first element in the specified - * lexicographical range. Returns REDISMODULE_OK if the iterator was correctly - * initialized otherwise REDISMODULE_ERR is returned in the + * lexicographical range. Returns VALKEYMODULE_OK if the iterator was correctly + * initialized otherwise VALKEYMODULE_ERR is returned in the * following conditions: * * 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 ValkeyModuleString 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 VM_ZsetFirstInLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) { return zsetInitLexRange(key,min,max,1); } -/* Exactly like RedisModule_ZsetFirstInLexRange() but the last element of +/* Exactly like ValkeyModule_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 VM_ZsetLastInLexRange(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *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; +ValkeyModuleString *VM_ZsetRangeCurrentElement(ValkeyModuleKey *key, double *score) { + ValkeyModuleString *str; if (!key->value || key->value->type != OBJ_ZSET) return NULL; if (key->u.zset.current == NULL) return NULL; @@ -5053,14 +5054,14 @@ RedisModuleString *RM_ZsetRangeCurrentElement(RedisModuleKey *key, double *score } else { serverPanic("Unsupported zset encoding"); } - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,str); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,str); return str; } /* 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 VM_ZsetRangeNext(ValkeyModuleKey *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. */ @@ -5075,7 +5076,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE) { + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE) { /* Fetch the next element score for the * range check. */ unsigned char *saved_next = next; @@ -5086,7 +5087,7 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } next = saved_next; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zzlLexValueLteMax(next,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5102,12 +5103,12 @@ int RM_ZsetRangeNext(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE && + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE && !zslValueLteMax(next->score,&key->u.zset.rs)) { key->u.zset.er = 1; return 0; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zslLexValueLteMax(next->ele,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5124,7 +5125,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 VM_ZsetRangePrev(ValkeyModuleKey *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. */ @@ -5139,7 +5140,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE) { + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE) { /* Fetch the previous element score for the * range check. */ unsigned char *saved_prev = prev; @@ -5150,7 +5151,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } prev = saved_prev; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zzlLexValueGteMin(prev,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5166,12 +5167,12 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { return 0; } else { /* Are we still within the range? */ - if (key->u.zset.type == REDISMODULE_ZSET_RANGE_SCORE && + if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_SCORE && !zslValueGteMin(prev->score,&key->u.zset.rs)) { key->u.zset.er = 1; return 0; - } else if (key->u.zset.type == REDISMODULE_ZSET_RANGE_LEX) { + } else if (key->u.zset.type == VALKEYMODULE_ZSET_RANGE_LEX) { if (!zslLexValueGteMin(prev->ele,&key->u.zset.lrs)) { key->u.zset.er = 1; return 0; @@ -5188,7 +5189,7 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { /* -------------------------------------------------------------------------- * ## Key API for Hash type * - * See also RM_ValueLength(), which returns the number of fields in a hash. + * See also VM_ValueLength(), which returns the number of fields in a hash. * -------------------------------------------------------------------------- */ /* Set the field of the specified hash field to the specified value. @@ -5196,33 +5197,33 @@ 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 ValkeyModuleString 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); + * ValkeyModule_HashSet(key,VALKEYMODULE_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: + * by setting them to the specified value of VALKEYMODULE_HASH_DELETE: * - * RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[1], - * REDISMODULE_HASH_DELETE,NULL); + * ValkeyModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[1], + * VALKEYMODULE_HASH_DELETE,NULL); * * The behavior of the command changes with the specified flags, that can be - * set to REDISMODULE_HASH_NONE if no special behavior is needed. + * set to VALKEYMODULE_HASH_NONE if no special behavior is needed. * - * REDISMODULE_HASH_NX: The operation is performed only if the field was not + * VALKEYMODULE_HASH_NX: The operation is performed only if the field was not * already existing in the hash. - * REDISMODULE_HASH_XX: The operation is performed only if the field was + * VALKEYMODULE_HASH_XX: The operation is performed only if the field was * already existing, so that a new value could be * 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. - * REDISMODULE_HASH_COUNT_ALL: Include the number of inserted fields in the + * VALKEYMODULE_HASH_CFIELDS: The field names passed are null terminated C + * strings instead of ValkeyModuleString objects. + * VALKEYMODULE_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 * 6.2.) @@ -5230,18 +5231,18 @@ int RM_ZsetRangePrev(RedisModuleKey *key) { * Unless NX is specified, the command overwrites the old field value with * the new one. * - * When using REDISMODULE_HASH_CFIELDS, field names are reported using + * When using VALKEYMODULE_HASH_CFIELDS, field names are reported using * normal C strings, so for example to delete the field "foo" the following * code can be used: * - * RedisModule_HashSet(key,REDISMODULE_HASH_CFIELDS,"foo", - * REDISMODULE_HASH_DELETE,NULL); + * ValkeyModule_HashSet(key,VALKEYMODULE_HASH_CFIELDS,"foo", + * VALKEYMODULE_HASH_DELETE,NULL); * * Return value: * * The number of fields existing in the hash prior to the call, which have been * updated (its old value has been replaced by a new value) or deleted. If the - * flag REDISMODULE_HASH_COUNT_ALL is set, inserted fields not previously + * flag VALKEYMODULE_HASH_COUNT_ALL is set, inserted fields not previously * existing in the hash are also counted. * * If the return value is zero, `errno` is set (since Redis 6.2) as follows: @@ -5258,53 +5259,53 @@ 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 VM_HashSet(ValkeyModuleKey *key, int flags, ...) { va_list ap; - if (!key || (flags & ~(REDISMODULE_HASH_NX | - REDISMODULE_HASH_XX | - REDISMODULE_HASH_CFIELDS | - REDISMODULE_HASH_COUNT_ALL))) { + if (!key || (flags & ~(VALKEYMODULE_HASH_NX | + VALKEYMODULE_HASH_XX | + VALKEYMODULE_HASH_CFIELDS | + VALKEYMODULE_HASH_COUNT_ALL))) { errno = EINVAL; return 0; } else if (key->value && key->value->type != OBJ_HASH) { errno = ENOTSUP; return 0; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return 0; } - if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_HASH); + if (key->value == NULL) moduleCreateEmptyKey(key,VALKEYMODULE_KEYTYPE_HASH); int count = 0; va_start(ap, flags); while(1) { - RedisModuleString *field, *value; + ValkeyModuleString *field, *value; /* Get the field and value objects. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_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,ValkeyModuleString*); if (field == NULL) break; } - value = va_arg(ap,RedisModuleString*); + value = va_arg(ap,ValkeyModuleString*); /* Handle XX and NX */ - if (flags & (REDISMODULE_HASH_XX|REDISMODULE_HASH_NX)) { + if (flags & (VALKEYMODULE_HASH_XX|VALKEYMODULE_HASH_NX)) { int exists = hashTypeExists(key->value, field->ptr); - if (((flags & REDISMODULE_HASH_XX) && !exists) || - ((flags & REDISMODULE_HASH_NX) && exists)) + if (((flags & VALKEYMODULE_HASH_XX) && !exists) || + ((flags & VALKEYMODULE_HASH_NX) && exists)) { - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); continue; } } - /* Handle deletion if value is REDISMODULE_HASH_DELETE. */ - if (value == REDISMODULE_HASH_DELETE) { + /* Handle deletion if value is VALKEYMODULE_HASH_DELETE. */ + if (value == VALKEYMODULE_HASH_DELETE) { count += hashTypeDelete(key->value, field->ptr); - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); continue; } @@ -5312,17 +5313,17 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) { /* If CFIELDS is active, we can pass the ownership of the * SDS object to the low level function that sets the field * to avoid a useless copy. */ - if (flags & REDISMODULE_HASH_CFIELDS) + if (flags & VALKEYMODULE_HASH_CFIELDS) low_flags |= HASH_SET_TAKE_FIELD; robj *argv[2] = {field,value}; hashTypeTryConversion(key->value,argv,0,1); int updated = hashTypeSet(key->value, field->ptr, value->ptr, low_flags); - count += (flags & REDISMODULE_HASH_COUNT_ALL) ? 1 : updated; + count += (flags & VALKEYMODULE_HASH_COUNT_ALL) ? 1 : updated; /* If CFIELDS is active, SDS string ownership is now of hashTypeSet(), * however we still have to release the 'field' object shell. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_HASH_CFIELDS) { field->ptr = NULL; /* Prevent the SDS string from being freed. */ decrRefCount(field); } @@ -5334,73 +5335,73 @@ 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 ValkeyModuleString + * pointer) with a pointer to a ValkeyModuleString 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, + * ValkeyModuleString *first, *second; + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_NONE,argv[1],&first, * argv[2],&second,NULL); * - * As with RedisModule_HashSet() the behavior of the command can be specified - * passing flags different than REDISMODULE_HASH_NONE: + * As with ValkeyModule_HashSet() the behavior of the command can be specified + * passing flags different than VALKEYMODULE_HASH_NONE: * - * REDISMODULE_HASH_CFIELDS: field names as null terminated C strings. + * VALKEYMODULE_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 + * VALKEYMODULE_HASH_EXISTS: instead of setting the value of the field + * expecting a ValkeyModuleString 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: + * Example of VALKEYMODULE_HASH_CFIELDS: * - * RedisModuleString *username, *hashedpass; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); + * ValkeyModuleString *username, *hashedpass; + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_CFIELDS,"username",&username,"hp",&hashedpass, NULL); * - * Example of REDISMODULE_HASH_EXISTS: + * Example of VALKEYMODULE_HASH_EXISTS: * * int exists; - * RedisModule_HashGet(mykey,REDISMODULE_HASH_EXISTS,argv[1],&exists,NULL); + * ValkeyModule_HashGet(mykey,VALKEYMODULE_HASH_EXISTS,argv[1],&exists,NULL); * - * The function returns REDISMODULE_OK on success and REDISMODULE_ERR if + * The function returns VALKEYMODULE_OK on success and VALKEYMODULE_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 ValkeyModuleString objects should be released with + * ValkeyModule_FreeString(), or by enabling automatic memory management. */ -int RM_HashGet(RedisModuleKey *key, int flags, ...) { +int VM_HashGet(ValkeyModuleKey *key, int flags, ...) { va_list ap; - if (key->value && key->value->type != OBJ_HASH) return REDISMODULE_ERR; + if (key->value && key->value->type != OBJ_HASH) return VALKEYMODULE_ERR; va_start(ap, flags); while(1) { - RedisModuleString *field, **valueptr; + ValkeyModuleString *field, **valueptr; int *existsptr; /* Get the field object and the value pointer to pointer. */ - if (flags & REDISMODULE_HASH_CFIELDS) { + if (flags & VALKEYMODULE_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,ValkeyModuleString*); if (field == NULL) break; } /* Query the hash for existence or value object. */ - if (flags & REDISMODULE_HASH_EXISTS) { + if (flags & VALKEYMODULE_HASH_EXISTS) { existsptr = va_arg(ap,int*); if (key->value) *existsptr = hashTypeExists(key->value,field->ptr); else *existsptr = 0; } else { - valueptr = va_arg(ap,RedisModuleString**); + valueptr = va_arg(ap,ValkeyModuleString**); if (key->value) { *valueptr = hashTypeGetValueObject(key->value,field->ptr); if (*valueptr) { @@ -5409,17 +5410,17 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { *valueptr = decoded; } if (*valueptr) - autoMemoryAdd(key->ctx,REDISMODULE_AM_STRING,*valueptr); + autoMemoryAdd(key->ctx,VALKEYMODULE_AM_STRING,*valueptr); } else { *valueptr = NULL; } } /* Cleanup */ - if (flags & REDISMODULE_HASH_CFIELDS) decrRefCount(field); + if (flags & VALKEYMODULE_HASH_CFIELDS) decrRefCount(field); } va_end(ap); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -5427,23 +5428,23 @@ 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 ValkeyModuleStreamID, which is used in stream functions, is a struct * with two 64-bit fields and is defined as * - * typedef struct RedisModuleStreamID { + * typedef struct ValkeyModuleStreamID { * uint64_t ms; * uint64_t seq; - * } RedisModuleStreamID; + * } ValkeyModuleStreamID; * - * See also RM_ValueLength(), which returns the length of a stream, and the - * conversion functions RM_StringToStreamID() and RM_CreateStringFromStreamID(). + * See also VM_ValueLength(), which returns the length of a stream, and the + * conversion functions VM_StringToStreamID() and VM_CreateStringFromStreamID(). * -------------------------------------------------------------------------- */ /* Adds an entry to a stream. Like XADD without trimming. * * - `key`: The key where the stream is (or will be) stored * - `flags`: A bit field of - * - `REDISMODULE_STREAM_ADD_AUTOID`: Assign a stream ID automatically, like + * - `VALKEYMODULE_STREAM_ADD_AUTOID`: Assign a stream ID automatically, like * `*` in the XADD command. * - `id`: If the `AUTOID` flag is set, this is where the assigned ID is * returned. Can be NULL if `AUTOID` is set, if you don't care to receive the @@ -5452,8 +5453,8 @@ int RM_HashGet(RedisModuleKey *key, int flags, ...) { * fields and values. * - `numfields`: The number of field-value pairs in `argv`. * - * Returns REDISMODULE_OK if an entry has been added. On failure, - * REDISMODULE_ERR is returned and `errno` is set as follows: + * Returns VALKEYMODULE_OK if an entry has been added. On failure, + * VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with invalid arguments * - ENOTSUP if the key refers to a value of a type other than stream @@ -5463,29 +5464,29 @@ 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 VM_StreamAdd(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id, ValkeyModuleString **argv, long numfields) { /* Validate args */ if (!key || (numfields != 0 && !argv) || /* invalid key or argv */ - (flags & ~(REDISMODULE_STREAM_ADD_AUTOID)) || /* invalid flags */ - (!(flags & REDISMODULE_STREAM_ADD_AUTOID) && !id)) { /* id required */ + (flags & ~(VALKEYMODULE_STREAM_ADD_AUTOID)) || /* invalid flags */ + (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID) && !id)) { /* id required */ errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->value && key->value->type != OBJ_STREAM) { errno = ENOTSUP; /* wrong type */ - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE)) { + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; /* key not open for writing */ - return REDISMODULE_ERR; - } else if (!(flags & REDISMODULE_STREAM_ADD_AUTOID) && + return VALKEYMODULE_ERR; + } else if (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID) && id->ms == 0 && id->seq == 0) { errno = EDOM; /* ID out of range */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Create key if necessary */ int created = 0; if (key->value == NULL) { - moduleCreateEmptyKey(key, REDISMODULE_KEYTYPE_STREAM); + moduleCreateEmptyKey(key, VALKEYMODULE_KEYTYPE_STREAM); created = 1; } @@ -5493,13 +5494,13 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM if (s->last_id.ms == UINT64_MAX && s->last_id.seq == UINT64_MAX) { /* The stream has reached the last possible ID */ errno = EFBIG; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamID added_id; streamID use_id; streamID *use_id_ptr = NULL; - if (!(flags & REDISMODULE_STREAM_ADD_AUTOID)) { + if (!(flags & VALKEYMODULE_STREAM_ADD_AUTOID)) { use_id.ms = id->ms; use_id.seq = id->seq; use_id_ptr = &use_id; @@ -5510,7 +5511,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * the elements are too large to be stored. either way, errno is already * set by streamAppendItem. */ if (created) moduleDelKeyIfEmpty(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Postponed signalKeyAsReady(). Done implicitly by moduleCreateEmptyKey() * so not needed if the stream has just been created. */ @@ -5521,7 +5522,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM id->seq = added_id.seq; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Deletes an entry from a stream. @@ -5529,7 +5530,7 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * - `key`: A key opened for writing, with no stream iterator started. * - `id`: The stream ID of the entry to delete. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with invalid arguments @@ -5539,44 +5540,44 @@ int RM_StreamAdd(RedisModuleKey *key, int flags, RedisModuleStreamID *id, RedisM * associated with the key * - ENOENT if no entry with the given stream ID exists * - * See also RM_StreamIteratorDelete() for deleting the current entry while + * See also VM_StreamIteratorDelete() for deleting the current entry while * iterating using a stream iterator. */ -int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { +int VM_StreamDelete(ValkeyModuleKey *key, ValkeyModuleStreamID *id) { if (!key || !id) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; /* wrong type */ - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE) || + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE) || key->iter != NULL) { errno = EBADF; /* key not opened for writing or iterator started */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } stream *s = key->value->ptr; streamID streamid = {id->ms, id->seq}; if (streamDeleteItem(s, &streamid)) { - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { errno = ENOENT; /* no entry with this id */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* Sets up a stream iterator. * - * - `key`: The stream key opened for reading using RedisModule_OpenKey(). + * - `key`: The stream key opened for reading using ValkeyModule_OpenKey(). * - `flags`: - * - `REDISMODULE_STREAM_ITERATOR_EXCLUSIVE`: Don't include `start` and `end` + * - `VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE`: Don't include `start` and `end` * in the iterated range. - * - `REDISMODULE_STREAM_ITERATOR_REVERSE`: Iterate in reverse order, starting + * - `VALKEYMODULE_STREAM_ITERATOR_REVERSE`: Iterate in reverse order, starting * from the `end` of the range. * - `start`: The lower bound of the range. Use NULL for the beginning of the * stream. * - `end`: The upper bound of the range. Use NULL for the end of the stream. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with invalid arguments @@ -5586,76 +5587,76 @@ int RM_StreamDelete(RedisModuleKey *key, RedisModuleStreamID *id) { * already associated with the key * - EDOM if `start` or `end` is outside the valid range * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR if the key doesn't + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_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 ValkeyModule_StreamIteratorNextID() and * for each stream ID, the fields and values are retrieved using - * RedisModule_StreamIteratorNextField(). The iterator is freed by calling - * RedisModule_StreamIteratorStop(). + * ValkeyModule_StreamIteratorNextField(). The iterator is freed by calling + * ValkeyModule_StreamIteratorStop(). * * Example (error handling omitted): * - * RedisModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); - * RedisModuleStreamID id; + * ValkeyModule_StreamIteratorStart(key, 0, startid_ptr, endid_ptr); + * ValkeyModuleStreamID id; * long numfields; - * while (RedisModule_StreamIteratorNextID(key, &id, &numfields) == - * REDISMODULE_OK) { - * RedisModuleString *field, *value; - * while (RedisModule_StreamIteratorNextField(key, &field, &value) == - * REDISMODULE_OK) { + * while (ValkeyModule_StreamIteratorNextID(key, &id, &numfields) == + * VALKEYMODULE_OK) { + * ValkeyModuleString *field, *value; + * while (ValkeyModule_StreamIteratorNextField(key, &field, &value) == + * VALKEYMODULE_OK) { * // * // ... Do stuff ... * // - * RedisModule_FreeString(ctx, field); - * RedisModule_FreeString(ctx, value); + * ValkeyModule_FreeString(ctx, field); + * ValkeyModule_FreeString(ctx, value); * } * } - * RedisModule_StreamIteratorStop(key); + * ValkeyModule_StreamIteratorStop(key); */ -int RM_StreamIteratorStart(RedisModuleKey *key, int flags, RedisModuleStreamID *start, RedisModuleStreamID *end) { +int VM_StreamIteratorStart(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *start, ValkeyModuleStreamID *end) { /* check args */ if (!key || - (flags & ~(REDISMODULE_STREAM_ITERATOR_EXCLUSIVE | - REDISMODULE_STREAM_ITERATOR_REVERSE))) { + (flags & ~(VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE | + VALKEYMODULE_STREAM_ITERATOR_REVERSE))) { errno = EINVAL; /* key missing or invalid flags */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; /* not a stream */ + return VALKEYMODULE_ERR; /* not a stream */ } else if (key->iter) { errno = EBADF; /* iterator already started */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* define range for streamIteratorStart() */ streamID lower, upper; if (start) lower = (streamID){start->ms, start->seq}; if (end) upper = (streamID){end->ms, end->seq}; - if (flags & REDISMODULE_STREAM_ITERATOR_EXCLUSIVE) { + if (flags & VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE) { if ((start && streamIncrID(&lower) != C_OK) || (end && streamDecrID(&upper) != C_OK)) { errno = EDOM; /* end is 0-0 or start is MAX-MAX? */ - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* create iterator */ stream *s = key->value->ptr; - int rev = flags & REDISMODULE_STREAM_ITERATOR_REVERSE; + int rev = flags & VALKEYMODULE_STREAM_ITERATOR_REVERSE; streamIterator *si = zmalloc(sizeof(*si)); streamIteratorStart(si, s, start ? &lower : NULL, end ? &upper : NULL, rev); key->iter = si; - key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ + key->u.stream.currentid.ms = 0; /* for VM_StreamIteratorDelete() */ key->u.stream.currentid.seq = 0; - key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ - return REDISMODULE_OK; + key->u.stream.numfieldsleft = 0; /* for VM_StreamIteratorNextField() */ + return VALKEYMODULE_OK; } -/* Stops a stream iterator created using RedisModule_StreamIteratorStart() and +/* Stops a stream iterator created using ValkeyModule_StreamIteratorStart() and * reclaims its memory. * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if called with a NULL key @@ -5664,34 +5665,34 @@ 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 VM_StreamIteratorStop(ValkeyModuleKey *key) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIteratorStop(key->iter); zfree(key->iter); key->iter = NULL; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Finds the next stream entry and returns its stream ID and the number of * fields. * * - `key`: Key for which a stream iterator has been started using - * RedisModule_StreamIteratorStart(). + * ValkeyModule_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. * - * Returns REDISMODULE_OK and sets `*id` and `*numfields` if an entry was found. - * On failure, REDISMODULE_ERR is returned and `errno` is set as follows: + * Returns VALKEYMODULE_OK and sets `*id` and `*numfields` if an entry was found. + * On failure, VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with a NULL key * - ENOTSUP if the key refers to a value of a type other than stream or if the @@ -5699,23 +5700,23 @@ int RM_StreamIteratorStop(RedisModuleKey *key) { * - EBADF if no stream iterator is associated with the key * - ENOENT if there are no more entries in the range of the iterator * - * In practice, if RM_StreamIteratorNextID() is called after a successful call - * 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. + * In practice, if VM_StreamIteratorNextID() is called after a successful call + * to VM_StreamIteratorStart() and with the same key, it is safe to assume that + * an VALKEYMODULE_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 ValkeyModule_StreamIteratorNextField() to retrieve the fields and values. + * See the example at ValkeyModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) { +int VM_StreamIteratorNextID(ValkeyModuleKey *key, ValkeyModuleStreamID *id, long *numfields) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; int64_t *num_ptr = &key->u.stream.numfieldsleft; @@ -5726,29 +5727,29 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * id->seq = streamid_ptr->seq; } if (numfields) *numfields = *num_ptr; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } else { /* No entry found. */ - key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ + key->u.stream.currentid.ms = 0; /* for VM_StreamIteratorDelete() */ key->u.stream.currentid.seq = 0; - key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ + key->u.stream.numfieldsleft = 0; /* for VM_StreamIteratorNextField() */ errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } /* 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. + * ValkeyModule_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 + * Returns VALKEYMODULE_OK and points `*field_ptr` and `*value_ptr` to freshly + * allocated ValkeyModuleString 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: + * failure, VALKEYMODULE_ERR is returned and `errno` is set as follows: * * - EINVAL if called with a NULL key * - ENOTSUP if the key refers to a value of a type other than stream or if the @@ -5756,25 +5757,25 @@ int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long * * - EBADF if no stream iterator is associated with the key * - ENOENT if there are no more fields in the current stream entry * - * In practice, if RM_StreamIteratorNextField() is called after a successful - * 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. + * In practice, if VM_StreamIteratorNextField() is called after a successful + * call to VM_StreamIteratorNextID() and with the same key, it is safe to assume + * that an VALKEYMODULE_ERR return value means that there are no more fields. * - * See the example at RedisModule_StreamIteratorStart(). + * See the example at ValkeyModule_StreamIteratorStart(). */ -int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) { +int VM_StreamIteratorNextField(ValkeyModuleKey *key, ValkeyModuleString **field_ptr, ValkeyModuleString **value_ptr) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->u.stream.numfieldsleft <= 0) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; unsigned char *field, *value; @@ -5782,22 +5783,22 @@ int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_pt streamIteratorGetField(si, &field, &value, &field_len, &value_len); if (field_ptr) { *field_ptr = createRawStringObject((char *)field, field_len); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *field_ptr); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, *field_ptr); } if (value_ptr) { *value_ptr = createRawStringObject((char *)value, value_len); - autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *value_ptr); + autoMemoryAdd(key->ctx, VALKEYMODULE_AM_STRING, *value_ptr); } key->u.stream.numfieldsleft--; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Deletes the current stream entry while iterating. * - * This function can be called after RM_StreamIteratorNextID() or after any - * calls to RM_StreamIteratorNextField(). + * This function can be called after VM_StreamIteratorNextID() or after any + * calls to VM_StreamIteratorNextField(). * - * Returns REDISMODULE_OK on success. On failure, REDISMODULE_ERR is returned + * Returns VALKEYMODULE_OK on success. On failure, VALKEYMODULE_ERR is returned * and `errno` is set as follows: * * - EINVAL if key is NULL @@ -5805,34 +5806,34 @@ 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 VM_StreamIteratorDelete(ValkeyModuleKey *key) { if (!key) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; - return REDISMODULE_ERR; - } else if (!(key->mode & REDISMODULE_WRITE) || !key->iter) { + return VALKEYMODULE_ERR; + } else if (!(key->mode & VALKEYMODULE_WRITE) || !key->iter) { errno = EBADF; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } else if (key->u.stream.currentid.ms == 0 && key->u.stream.currentid.seq == 0) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } streamIterator *si = key->iter; streamIteratorRemoveEntry(si, &key->u.stream.currentid); key->u.stream.currentid.ms = 0; /* Make sure repeated Delete() fails */ key->u.stream.currentid.seq = 0; key->u.stream.numfieldsleft = 0; /* Make sure NextField() fails */ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Trim a stream by length, similar to XTRIM with MAXLEN. * * - `key`: Key opened for writing. * - `flags`: A bitfield of - * - `REDISMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, + * - `VALKEYMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, * like XTRIM with `~`. * - `length`: The number of stream entries to keep after trimming. * @@ -5843,18 +5844,18 @@ 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) { - if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || length < 0) { +long long VM_StreamTrimByLength(ValkeyModuleKey *key, int flags, long long length) { + if (!key || (flags & ~(VALKEYMODULE_STREAM_TRIM_APPROX)) || length < 0) { errno = EINVAL; return -1; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; return -1; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return -1; } - int approx = flags & REDISMODULE_STREAM_TRIM_APPROX ? 1 : 0; + int approx = flags & VALKEYMODULE_STREAM_TRIM_APPROX ? 1 : 0; return streamTrimByLength((stream *)key->value->ptr, length, approx); } @@ -5862,7 +5863,7 @@ long long RM_StreamTrimByLength(RedisModuleKey *key, int flags, long long length * * - `key`: Key opened for writing. * - `flags`: A bitfield of - * - `REDISMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, + * - `VALKEYMODULE_STREAM_TRIM_APPROX`: Trim less if it improves performance, * like XTRIM with `~`. * - `id`: The smallest stream ID to keep after trimming. * @@ -5873,18 +5874,18 @@ 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) { - if (!key || (flags & ~(REDISMODULE_STREAM_TRIM_APPROX)) || !id) { +long long VM_StreamTrimByID(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id) { + if (!key || (flags & ~(VALKEYMODULE_STREAM_TRIM_APPROX)) || !id) { errno = EINVAL; return -1; } else if (!key->value || key->value->type != OBJ_STREAM) { errno = ENOTSUP; return -1; - } else if (!(key->mode & REDISMODULE_WRITE)) { + } else if (!(key->mode & VALKEYMODULE_WRITE)) { errno = EBADF; return -1; } - int approx = flags & REDISMODULE_STREAM_TRIM_APPROX ? 1 : 0; + int approx = flags & VALKEYMODULE_STREAM_TRIM_APPROX ? 1 : 0; streamID minid = (streamID){id->ms, id->seq}; return streamTrimByID((stream *)key->value->ptr, minid, approx); } @@ -5892,28 +5893,28 @@ long long RM_StreamTrimByID(RedisModuleKey *key, int flags, RedisModuleStreamID /* -------------------------------------------------------------------------- * ## Calling Redis commands from modules * - * RM_Call() sends a command to Redis. The remaining functions handle the reply. + * VM_Call() sends a command to Redis. The remaining functions handle the reply. * -------------------------------------------------------------------------- */ -void moduleParseCallReply_Int(RedisModuleCallReply *reply); -void moduleParseCallReply_BulkString(RedisModuleCallReply *reply); -void moduleParseCallReply_SimpleString(RedisModuleCallReply *reply); -void moduleParseCallReply_Array(RedisModuleCallReply *reply); +void moduleParseCallReply_Int(ValkeyModuleCallReply *reply); +void moduleParseCallReply_BulkString(ValkeyModuleCallReply *reply); +void moduleParseCallReply_SimpleString(ValkeyModuleCallReply *reply); +void moduleParseCallReply_Array(ValkeyModuleCallReply *reply); /* Free a Call reply and all the nested replies it contains if it's an * array. */ -void RM_FreeCallReply(RedisModuleCallReply *reply) { +void VM_FreeCallReply(ValkeyModuleCallReply *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; - if(callReplyType(reply) == REDISMODULE_REPLY_PROMISE) { - RedisModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); + ValkeyModuleCtx *ctx = NULL; + if(callReplyType(reply) == VALKEYMODULE_REPLY_PROMISE) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); ctx = promise->ctx; freeRedisModuleAsyncRMCallPromise(promise); } else { @@ -5922,131 +5923,131 @@ void RM_FreeCallReply(RedisModuleCallReply *reply) { freeCallReply(reply); if (ctx) { - autoMemoryFreed(ctx,REDISMODULE_AM_REPLY,reply); + autoMemoryFreed(ctx,VALKEYMODULE_AM_REPLY,reply); } } /* Return the reply type as one of the following: * - * - REDISMODULE_REPLY_UNKNOWN - * - REDISMODULE_REPLY_STRING - * - REDISMODULE_REPLY_ERROR - * - REDISMODULE_REPLY_INTEGER - * - REDISMODULE_REPLY_ARRAY - * - REDISMODULE_REPLY_NULL - * - REDISMODULE_REPLY_MAP - * - REDISMODULE_REPLY_SET - * - REDISMODULE_REPLY_BOOL - * - REDISMODULE_REPLY_DOUBLE - * - REDISMODULE_REPLY_BIG_NUMBER - * - REDISMODULE_REPLY_VERBATIM_STRING - * - REDISMODULE_REPLY_ATTRIBUTE - * - REDISMODULE_REPLY_PROMISE */ -int RM_CallReplyType(RedisModuleCallReply *reply) { + * - VALKEYMODULE_REPLY_UNKNOWN + * - VALKEYMODULE_REPLY_STRING + * - VALKEYMODULE_REPLY_ERROR + * - VALKEYMODULE_REPLY_INTEGER + * - VALKEYMODULE_REPLY_ARRAY + * - VALKEYMODULE_REPLY_NULL + * - VALKEYMODULE_REPLY_MAP + * - VALKEYMODULE_REPLY_SET + * - VALKEYMODULE_REPLY_BOOL + * - VALKEYMODULE_REPLY_DOUBLE + * - VALKEYMODULE_REPLY_BIG_NUMBER + * - VALKEYMODULE_REPLY_VERBATIM_STRING + * - VALKEYMODULE_REPLY_ATTRIBUTE + * - VALKEYMODULE_REPLY_PROMISE */ +int VM_CallReplyType(ValkeyModuleCallReply *reply) { return callReplyType(reply); } /* Return the reply type length, where applicable. */ -size_t RM_CallReplyLength(RedisModuleCallReply *reply) { +size_t VM_CallReplyLength(ValkeyModuleCallReply *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) { +ValkeyModuleCallReply *VM_CallReplyArrayElement(ValkeyModuleCallReply *reply, size_t idx) { return callReplyGetArrayElement(reply, idx); } /* Return the `long long` of an integer reply. */ -long long RM_CallReplyInteger(RedisModuleCallReply *reply) { +long long VM_CallReplyInteger(ValkeyModuleCallReply *reply) { return callReplyGetLongLong(reply); } /* Return the double value of a double reply. */ -double RM_CallReplyDouble(RedisModuleCallReply *reply) { +double VM_CallReplyDouble(ValkeyModuleCallReply *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 *VM_CallReplyBigNumber(ValkeyModuleCallReply *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 *VM_CallReplyVerbatim(ValkeyModuleCallReply *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 VM_CallReplyBool(ValkeyModuleCallReply *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) { +ValkeyModuleCallReply *VM_CallReplySetElement(ValkeyModuleCallReply *reply, size_t idx) { return callReplyGetSetElement(reply, idx); } /* Retrieve the 'idx'-th key and value of a map reply. * * Returns: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if idx out of range or if the reply type is wrong. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if idx out of range or if the reply type is wrong. * * 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 VM_CallReplyMapElement(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) { if (callReplyGetMapElement(reply, idx, key, val) == C_OK){ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Return the attribute of the given reply, or NULL if no attribute exists. */ -RedisModuleCallReply *RM_CallReplyAttribute(RedisModuleCallReply *reply) { +ValkeyModuleCallReply *VM_CallReplyAttribute(ValkeyModuleCallReply *reply) { return callReplyGetAttribute(reply); } /* Retrieve the 'idx'-th key and value of an attribute reply. * * Returns: - * - REDISMODULE_OK on success. - * - REDISMODULE_ERR if idx out of range or if the reply type is wrong. + * - VALKEYMODULE_OK on success. + * - VALKEYMODULE_ERR if idx out of range or if the reply type is wrong. * * 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 VM_CallReplyAttributeElement(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) { if (callReplyGetAttributeElement(reply, idx, key, val) == C_OK){ - return REDISMODULE_OK; + return VALKEYMODULE_OK; } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } -/* Set unblock handler (callback and private data) on the given promise RedisModuleCallReply. - * 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); +/* Set unblock handler (callback and private data) on the given promise ValkeyModuleCallReply. + * The given reply must be of promise type (VALKEYMODULE_REPLY_PROMISE). */ +void VM_CallReplyPromiseSetUnblockHandler(ValkeyModuleCallReply *reply, ValkeyModuleOnUnblocked on_unblock, void *private_data) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); promise->on_unblocked = on_unblock; promise->private_data = private_data; } -/* Abort the execution of a given promise RedisModuleCallReply. - * return REDMODULE_OK in case the abort was done successfully and REDISMODULE_ERR +/* Abort the execution of a given promise ValkeyModuleCallReply. + * return REDMODULE_OK in case the abort was done successfully and VALKEYMODULE_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 - * will be set with the value of the private data that was given on 'RM_CallReplyPromiseSetUnblockHandler' + * will be set with the value of the private data that was given on 'VM_CallReplyPromiseSetUnblockHandler' * so the caller will be able to release the private data. * * If the execution was aborted successfully, it is promised that the unblock handler will not be called. * 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); - 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. */ +int VM_CallReplyPromiseAbort(ValkeyModuleCallReply *reply, void **private_data) { + ValkeyModuleAsyncRMCallPromise *promise = callReplyGetPrivateData(reply); + if (!promise->c) return VALKEYMODULE_ERR; /* Promise can not be aborted, either already aborted or already finished. */ + if (!(promise->c->flags & CLIENT_BLOCKED)) return VALKEYMODULE_ERR; /* Client is not blocked anymore, can not abort it. */ /* Client is still blocked, remove it from any blocking state and release it. */ if (private_data) *private_data = promise->private_data; @@ -6054,11 +6055,11 @@ int RM_CallReplyPromiseAbort(RedisModuleCallReply *reply, void **private_data) { promise->on_unblocked = NULL; unblockClient(promise->c, 0); moduleReleaseTempClient(promise->c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Return the pointer and length of a string or error reply. */ -const char *RM_CallReplyStringPtr(RedisModuleCallReply *reply, size_t *len) { +const char *VM_CallReplyStringPtr(ValkeyModuleCallReply *reply, size_t *len) { size_t private_len; if (!len) len = &private_len; return callReplyGetString(reply, len); @@ -6066,45 +6067,45 @@ 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); +ValkeyModuleString *VM_CreateStringFromCallReply(ValkeyModuleCallReply *reply) { + ValkeyModuleCtx* ctx = callReplyGetPrivateData(reply); size_t len; const char *str; switch(callReplyType(reply)) { - case REDISMODULE_REPLY_STRING: - case REDISMODULE_REPLY_ERROR: + case VALKEYMODULE_REPLY_STRING: + case VALKEYMODULE_REPLY_ERROR: str = callReplyGetString(reply, &len); - return RM_CreateString(ctx, str, len); - case REDISMODULE_REPLY_INTEGER: { + return VM_CreateString(ctx, str, len); + case VALKEYMODULE_REPLY_INTEGER: { char buf[64]; int len = ll2string(buf,sizeof(buf),callReplyGetLongLong(reply)); - return RM_CreateString(ctx ,buf,len); + return VM_CreateString(ctx ,buf,len); } default: return NULL; } } -/* Modifies the user that RM_Call will use (e.g. for ACL checks) */ -void RM_SetContextUser(RedisModuleCtx *ctx, const RedisModuleUser *user) { +/* Modifies the user that VM_Call will use (e.g. for ACL checks) */ +void VM_SetContextUser(ValkeyModuleCtx *ctx, const ValkeyModuleUser *user) { ctx->user = user; } /* Returns an array of robj pointers, by parsing the format specifier "fmt" as described for - * the RM_Call(), RM_Replicate() and other module APIs. Populates *argcp with the number of + * the VM_Call(), VM_Replicate() and other module APIs. Populates *argcp with the number of * items (which equals to the length of the allocated argv). * * The integer pointed by 'flags' is populated with flags according * to special modifiers in "fmt". * - * "!" -> REDISMODULE_ARGV_REPLICATE - * "A" -> REDISMODULE_ARGV_NO_AOF - * "R" -> REDISMODULE_ARGV_NO_REPLICAS - * "3" -> REDISMODULE_ARGV_RESP_3 - * "0" -> REDISMODULE_ARGV_RESP_AUTO - * "C" -> REDISMODULE_ARGV_RUN_AS_USER - * "M" -> REDISMODULE_ARGV_RESPECT_DENY_OOM - * "K" -> REDISMODULE_ARGV_ALLOW_BLOCK + * "!" -> VALKEYMODULE_ARGV_REPLICATE + * "A" -> VALKEYMODULE_ARGV_NO_AOF + * "R" -> VALKEYMODULE_ARGV_NO_REPLICAS + * "3" -> VALKEYMODULE_ARGV_RESP_3 + * "0" -> VALKEYMODULE_ARGV_RESP_AUTO + * "C" -> VALKEYMODULE_ARGV_RUN_AS_USER + * "M" -> VALKEYMODULE_ARGV_RESPECT_DENY_OOM + * "K" -> VALKEYMODULE_ARGV_ALLOW_BLOCK * * On error (format specifier error) NULL is returned and nothing is * allocated. On success the argument vector is returned. */ @@ -6158,29 +6159,29 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int argv[argc++] = v[i]; } } else if (*p == '!') { - if (flags) (*flags) |= REDISMODULE_ARGV_REPLICATE; + if (flags) (*flags) |= VALKEYMODULE_ARGV_REPLICATE; } else if (*p == 'A') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_AOF; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_AOF; } else if (*p == 'R') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_REPLICAS; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_REPLICAS; } else if (*p == '3') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESP_3; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESP_3; } else if (*p == '0') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESP_AUTO; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESP_AUTO; } else if (*p == 'C') { - if (flags) (*flags) |= REDISMODULE_ARGV_RUN_AS_USER; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RUN_AS_USER; } else if (*p == 'S') { - if (flags) (*flags) |= REDISMODULE_ARGV_SCRIPT_MODE; + if (flags) (*flags) |= VALKEYMODULE_ARGV_SCRIPT_MODE; } else if (*p == 'W') { - if (flags) (*flags) |= REDISMODULE_ARGV_NO_WRITES; + if (flags) (*flags) |= VALKEYMODULE_ARGV_NO_WRITES; } else if (*p == 'M') { - if (flags) (*flags) |= REDISMODULE_ARGV_RESPECT_DENY_OOM; + if (flags) (*flags) |= VALKEYMODULE_ARGV_RESPECT_DENY_OOM; } else if (*p == 'E') { - if (flags) (*flags) |= REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS; + if (flags) (*flags) |= VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS; } else if (*p == 'D') { - if (flags) (*flags) |= (REDISMODULE_ARGV_DRY_RUN | REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS); + if (flags) (*flags) |= (VALKEYMODULE_ARGV_DRY_RUN | VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS); } else if (*p == 'K') { - if (flags) (*flags) |= REDISMODULE_ARGV_ALLOW_BLOCK; + if (flags) (*flags) |= VALKEYMODULE_ARGV_ALLOW_BLOCK; } else { goto fmterr; } @@ -6208,22 +6209,22 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * 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 ValkeyModuleString. + * * `v` -- The argument(s) is a vector of ValkeyModuleString. * * `!` -- 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 ValkeyModuleCtx. 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 - * issued the command and created the context or via RM_SetContextUser. + * issued the command and created the context or via VM_SetContextUser. * If the context is not directly created by an issued command (such as a - * background context and no user was set on it via RM_SetContextUser, - * RM_Call will fail. + * background context and no user was set on it via VM_SetContextUser, + * VM_Call will fail. * Checks if the command can be executed according to ACL rules and causes * the command to run as the determined user, so that any future user * dependent activity, such as ACL checks within scripts will proceed as @@ -6237,7 +6238,7 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * 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 ValkeyModuleCallReply. 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. @@ -6246,36 +6247,36 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * return with a CallReply object denoting the error, as if it was called with * the 'E' code. * * 'K' -- Allow running blocking commands. If enabled and the command gets blocked, a - * special REDISMODULE_REPLY_PROMISE will be returned. This reply type + * special VALKEYMODULE_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 ValkeyModule_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 ValkeyModule_CallReplyPromiseAbort to abort the command invocation + * if it was not yet finished (see ValkeyModule_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. * Unlike other call replies, promise call reply **must** be freed while the Redis GIL is locked. * Notice that on unblocking, the only promise is that the unblock handler will be called, - * If the blocking RM_Call caused the module to also block some real client (using RM_BlockClient), + * If the blocking VM_Call caused the module to also block some real client (using VM_BlockClient), * it is the module responsibility to unblock this client on the unblock handler. * On the unblock handler it is only allowed to perform the following: - * * Calling additional Redis commands using RM_Call - * * Open keys using RM_OpenKey + * * Calling additional Redis commands using VM_Call + * * Open keys using VM_OpenKey * * Replicate data to the replica or AOF * * Specifically, it is not allowed to call any Redis module API which are client related such as: - * * RM_Reply* API's - * * RM_BlockClient - * * RM_GetCurrentUserName + * * VM_Reply* API's + * * VM_BlockClient + * * VM_GetCurrentUserName * * * **...**: The actual arguments to the Redis command. * - * On success a RedisModuleCallReply object is returned, otherwise + * On success a ValkeyModuleCallReply object is returned, otherwise * NULL is returned and errno is set to the following values: * * * EBADF: wrong format specifier. @@ -6292,53 +6293,53 @@ robj **moduleCreateArgvFromUserFormat(const char *cmdname, const char *fmt, int * * 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 = ValkeyModule_Call(ctx,"INCRBY","sc",argv[1],"10"); + * if (ValkeyModule_CallReplyType(reply) == VALKEYMODULE_REPLY_INTEGER) { + * long long myval = ValkeyModule_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, ...) { +ValkeyModuleCallReply *VM_Call(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) { client *c = NULL; robj **argv = NULL; int argc = 0, flags = 0; va_list ap; - RedisModuleCallReply *reply = NULL; + ValkeyModuleCallReply *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 ValkeyModuleCallReply object */ uint64_t cmd_flags; /* Handle arguments. */ va_start(ap, fmt); argv = moduleCreateArgvFromUserFormat(cmdname,fmt,&argc,&flags,ap); - replicate = flags & REDISMODULE_ARGV_REPLICATE; - error_as_call_replies = flags & REDISMODULE_ARGV_CALL_REPLIES_AS_ERRORS; + replicate = flags & VALKEYMODULE_ARGV_REPLICATE; + error_as_call_replies = flags & VALKEYMODULE_ARGV_CALL_REPLIES_AS_ERRORS; va_end(ap); c = moduleAllocTempClient(); - if (!(flags & REDISMODULE_ARGV_ALLOW_BLOCK)) { + if (!(flags & VALKEYMODULE_ARGV_ALLOW_BLOCK)) { /* We do not want to allow block, the module do not expect it */ c->flags |= CLIENT_DENY_BLOCKING; } c->db = ctx->client->db; c->argv = argv; - /* We have to assign argv_len, which is equal to argc in that case (RM_Call) + /* We have to assign argv_len, which is equal to argc in that case (VM_Call) * because we may be calling a command that uses rewriteClientCommandArgument */ c->argc = c->argv_len = argc; c->resp = 2; - if (flags & REDISMODULE_ARGV_RESP_3) { + if (flags & VALKEYMODULE_ARGV_RESP_3) { c->resp = 3; - } else if (flags & REDISMODULE_ARGV_RESP_AUTO) { + } else if (flags & VALKEYMODULE_ARGV_RESP_AUTO) { /* Auto mode means to take the same protocol as the ctx client. */ c->resp = ctx->client->resp; } if (ctx->module) ctx->module->in_call++; user *user = NULL; - if (flags & REDISMODULE_ARGV_RUN_AS_USER) { + if (flags & VALKEYMODULE_ARGV_RUN_AS_USER) { user = ctx->user ? ctx->user->user : ctx->client->user; if (!user) { errno = ENOTSUP; @@ -6385,7 +6386,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch cmd_flags = getCommandFlags(c); - if (flags & REDISMODULE_ARGV_SCRIPT_MODE) { + if (flags & VALKEYMODULE_ARGV_SCRIPT_MODE) { /* Basically on script mode we want to only allow commands that can * be executed on scripts (CMD_NOSCRIPT is not set on the command flags) */ if (cmd_flags & CMD_NOSCRIPT) { @@ -6398,10 +6399,10 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } - if (flags & REDISMODULE_ARGV_RESPECT_DENY_OOM && server.maxmemory) { + if (flags & VALKEYMODULE_ARGV_RESPECT_DENY_OOM && server.maxmemory) { if (cmd_flags & CMD_DENYOOM) { int oom_state; - if (ctx->flags & REDISMODULE_CTX_THREAD_SAFE) { + if (ctx->flags & VALKEYMODULE_CTX_THREAD_SAFE) { /* On background thread we can not count on server.pre_command_oom_state. * Because it is only set on the main thread, in such case we will check * the actual memory usage. */ @@ -6419,11 +6420,11 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } } else { - /* if we aren't OOM checking in RM_Call, we want further executions from this client to also not fail on OOM */ + /* if we aren't OOM checking in VM_Call, we want further executions from this client to also not fail on OOM */ c->flags |= CLIENT_ALLOW_OOM; } - if (flags & REDISMODULE_ARGV_NO_WRITES) { + if (flags & VALKEYMODULE_ARGV_NO_WRITES) { if (cmd_flags & CMD_WRITE) { errno = ENOSPC; if (error_as_call_replies) { @@ -6436,7 +6437,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } /* Script mode tests */ - if (flags & REDISMODULE_ARGV_SCRIPT_MODE) { + if (flags & VALKEYMODULE_ARGV_SCRIPT_MODE) { if (cmd_flags & CMD_WRITE) { /* on script mode, if a command is a write command, * We will not run it if we encounter disk error @@ -6487,10 +6488,10 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* Check if the user can run this command according to the current * ACLs. * - * If RM_SetContextUser has set a user, that user is used, otherwise + * If VM_SetContextUser has set a user, that user is used, otherwise * use the attached client's user. If there is no attached client user and no manually * set user, an error will be returned */ - if (flags & REDISMODULE_ARGV_RUN_AS_USER) { + if (flags & VALKEYMODULE_ARGV_RUN_AS_USER) { int acl_errpos; int acl_retval; @@ -6545,15 +6546,15 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } } - if (flags & REDISMODULE_ARGV_DRY_RUN) { + if (flags & VALKEYMODULE_ARGV_DRY_RUN) { goto cleanup; } /* We need to use a global replication_allowed flag in order to prevent - * replication of nested RM_Calls. Example: - * 1. module1.foo does RM_Call of module2.bar without replication (i.e. no '!') - * 2. module2.bar internally calls RM_Call of INCR with '!' - * 3. at the end of module1.foo we call RM_ReplicateVerbatim + * replication of nested VM_Calls. Example: + * 1. module1.foo does VM_Call of module2.bar without replication (i.e. no '!') + * 2. module2.bar internally calls VM_Call of INCR with '!' + * 3. at the end of module1.foo we call VM_ReplicateVerbatim * We want the replica/AOF to see only module1.foo and not the INCR from module2.bar */ int prev_replication_allowed = server.replication_allowed; server.replication_allowed = replicate && server.replication_allowed; @@ -6561,19 +6562,19 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* Run the command */ int call_flags = CMD_CALL_FROM_MODULE; if (replicate) { - if (!(flags & REDISMODULE_ARGV_NO_AOF)) + if (!(flags & VALKEYMODULE_ARGV_NO_AOF)) call_flags |= CMD_CALL_PROPAGATE_AOF; - if (!(flags & REDISMODULE_ARGV_NO_REPLICAS)) + if (!(flags & VALKEYMODULE_ARGV_NO_REPLICAS)) call_flags |= CMD_CALL_PROPAGATE_REPL; } call(c,call_flags); server.replication_allowed = prev_replication_allowed; if (c->flags & CLIENT_BLOCKED) { - serverAssert(flags & REDISMODULE_ARGV_ALLOW_BLOCK); + serverAssert(flags & VALKEYMODULE_ARGV_ALLOW_BLOCK); serverAssert(ctx->module); - RedisModuleAsyncRMCallPromise *promise = zmalloc(sizeof(RedisModuleAsyncRMCallPromise)); - *promise = (RedisModuleAsyncRMCallPromise) { + ValkeyModuleAsyncRMCallPromise *promise = zmalloc(sizeof(ValkeyModuleAsyncRMCallPromise)); + *promise = (ValkeyModuleAsyncRMCallPromise) { /* 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, @@ -6581,7 +6582,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch .on_unblocked = NULL, .private_data = NULL, .c = c, - .ctx = (ctx->flags & REDISMODULE_CTX_AUTO_MEMORY) ? ctx : NULL, + .ctx = (ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY) ? ctx : NULL, }; reply = callReplyCreatePromise(promise); c->bstate.async_rm_call_handle = promise; @@ -6595,11 +6596,11 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch } c = NULL; /* Make sure not to free the client */ } else { - reply = moduleParseReply(c, (ctx->flags & REDISMODULE_CTX_AUTO_MEMORY) ? ctx : NULL); + reply = moduleParseReply(c, (ctx->flags & VALKEYMODULE_CTX_AUTO_MEMORY) ? ctx : NULL); } cleanup: - if (reply) autoMemoryAdd(ctx,REDISMODULE_AM_REPLY,reply); + if (reply) autoMemoryAdd(ctx,VALKEYMODULE_AM_REPLY,reply); if (ctx->module) ctx->module->in_call--; if (c) moduleReleaseTempClient(c); return reply; @@ -6607,7 +6608,7 @@ RedisModuleCallReply *RM_Call(RedisModuleCtx *ctx, const char *cmdname, const ch /* 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 *VM_CallReplyProto(ValkeyModuleCallReply *reply, size_t *len) { return callReplyGetProto(reply, len); } @@ -6675,7 +6676,7 @@ moduleType *moduleTypeLookupModuleByNameInternal(const char *name, int ignore_ca dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6725,7 +6726,7 @@ moduleType *moduleTypeLookupModuleByID(uint64_t id) { dictEntry *de; while ((de = dictNext(di)) != NULL && mt == NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -6774,9 +6775,9 @@ const char *moduleTypeModuleName(moduleType *mt) { /* Return the module name from a module command */ const char *moduleNameFromCommand(struct serverCommand *cmd) { - serverAssert(cmd->proc == RedisModuleCommandDispatcher); + serverAssert(cmd->proc == ValkeyModuleCommandDispatcher); - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; return cp->module->name; } @@ -6792,7 +6793,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}; + ValkeyModuleKeyOptCtx ctx = {fromkey, tokey, c->db->id, todb}; newval = mt->copy2(&ctx, mv->value); } else { newval = mt->copy(fromkey, tokey, mv->value); @@ -6827,12 +6828,12 @@ 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 ValkeyModuleTypeMethods structure * that should be populated with the methods callbacks and structure * version, like in the following example: * - * RedisModuleTypeMethods tm = { - * .version = REDISMODULE_TYPE_METHOD_VERSION, + * ValkeyModuleTypeMethods tm = { + * .version = VALKEYMODULE_TYPE_METHOD_VERSION, * .rdb_load = myType_RDBLoadCallBack, * .rdb_save = myType_RDBSaveCallBack, * .aof_rewrite = myType_AOFRewriteCallBack, @@ -6861,9 +6862,9 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * * **digest**: A callback function pointer that is used for `DEBUG DIGEST`. * * **free**: A callback function pointer that can free a type value. * * **aux_save**: A callback function pointer that saves out of keyspace data to RDB files. - * 'when' argument is either REDISMODULE_AUX_BEFORE_RDB or REDISMODULE_AUX_AFTER_RDB. + * 'when' argument is either VALKEYMODULE_AUX_BEFORE_RDB or VALKEYMODULE_AUX_AFTER_RDB. * * **aux_load**: A callback function pointer that loads out of keyspace data from RDB files. - * Similar to aux_save, returns REDISMODULE_OK on success, and ERR otherwise. + * Similar to aux_save, returns VALKEYMODULE_OK on success, and ERR otherwise. * * **free_effort**: A callback function pointer that used to determine whether the module's * memory needs to be lazy reclaimed. The module should return the complexity involved by * freeing the value. for example: how many pointers are gonna be freed. Note that if it @@ -6871,7 +6872,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. + * ValkeyModuleEvent_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. @@ -6880,28 +6881,28 @@ robj *moduleTypeDupOrReply(client *c, robj *fromkey, robj *tokey, int todb, robj * called first, followed by a free callback to the value that is being replaced. * * * **defrag**: A callback function pointer that is used to request the module to defrag - * a key. The module should then iterate pointers and call the relevant RM_Defrag*() + * a key. The module should then iterate pointers and call the relevant VM_Defrag*() * functions to defragment pointers or complex types. The module should continue - * iterating as long as RM_DefragShouldStop() returns a zero value, and return a + * iterating as long as VM_DefragShouldStop() returns a zero value, and return a * zero value if finished or non-zero value if more work is left to be done. If more work - * needs to be done, RM_DefragCursorSet() and RM_DefragCursorGet() can be used to track + * needs to be done, VM_DefragCursorSet() and VM_DefragCursorGet() can be used to track * this work across different calls. * Normally, the defrag mechanism invokes the callback without a time limit, so - * RM_DefragShouldStop() always returns zero. The "late defrag" mechanism which has + * VM_DefragShouldStop() always returns zero. The "late defrag" mechanism which has * a time limit and provides cursor support is used only for keys that are determined * to have significant internal complexity. To determine this, the defrag mechanism * uses the free_effort callback and the 'active-defrag-max-scan-fields' config directive. * 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 `ValkeyModuleKeyOptCtx` 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 `ValkeyModuleKeyOptCtx` 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 `ValkeyModuleKeyOptCtx` 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 `ValkeyModuleKeyOptCtx` 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 @@ -6910,23 +6911,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 ValkeyModule_CreateDataType() is called outside of ValkeyModule_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 ValkeyModuleType 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 ValkeyModuleType *BalancedTreeType; * - * int RedisModule_OnLoad(RedisModuleCtx *ctx) { + * int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx) { * // some code here ... - * BalancedTreeType = RM_CreateDataType(...); + * BalancedTreeType = VM_CreateDataType(...); * } */ -moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { +moduleType *VM_CreateDataType(ValkeyModuleCtx *ctx, const char *name, int encver, void *typemethods_ptr) { if (!ctx->module->onload) return NULL; uint64_t id = moduleTypeEncodeId(name,encver); @@ -7002,41 +7003,41 @@ moduleType *RM_CreateDataType(RedisModuleCtx *ctx, const char *name, int encver, /* If the key is open for writing, set the specified module type object * 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) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) return REDISMODULE_ERR; - RM_DeleteKey(key); + * On success VALKEYMODULE_OK is returned. If the key is not open for + * writing or there is an active iterator, VALKEYMODULE_ERR is returned. */ +int VM_ModuleTypeSetValue(ValkeyModuleKey *key, moduleType *mt, void *value) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) return VALKEYMODULE_ERR; + VM_DeleteKey(key); robj *o = createModuleObject(mt,value); setKey(key->ctx->client,key->db,key->key,o,SETKEY_NO_SIGNAL); decrRefCount(o); key->value = o; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming ValkeyModule_KeyType() returned VALKEYMODULE_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 *VM_ModuleTypeGetType(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL || - RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; + VM_KeyType(key) != VALKEYMODULE_KEYTYPE_MODULE) return NULL; moduleValue *mv = key->value->ptr; return mv->type; } -/* Assuming RedisModule_KeyType() returned REDISMODULE_KEYTYPE_MODULE on +/* Assuming ValkeyModule_KeyType() returned VALKEYMODULE_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 ValkeyModule_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 *VM_ModuleTypeGetValue(ValkeyModuleKey *key) { if (key == NULL || key->value == NULL || - RM_KeyType(key) != REDISMODULE_KEYTYPE_MODULE) return NULL; + VM_KeyType(key) != VALKEYMODULE_KEYTYPE_MODULE) return NULL; moduleValue *mv = key->value->ptr; return mv->value; } @@ -7048,8 +7049,8 @@ 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) { - if (io->type->module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) { +void moduleRDBLoadError(ValkeyModuleIO *io) { + if (io->type->module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS) { io->error = 1; return; } @@ -7065,16 +7066,16 @@ void moduleRDBLoadError(RedisModuleIO *io) { } /* Returns 0 if there's at least one registered data type that did not declare - * REDISMODULE_OPTIONS_HANDLE_IO_ERRORS, in which case diskless loading should + * VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS, in which case diskless loading should * be avoided since it could cause data loss. */ int moduleAllDatatypesHandleErrors(void) { dictIterator *di = dictGetIterator(modules); dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); if (listLength(module->types) && - !(module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS)) + !(module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS)) { dictReleaseIterator(di); return 0; @@ -7084,7 +7085,7 @@ int moduleAllDatatypesHandleErrors(void) { return 1; } -/* Returns 0 if module did not declare REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD, in which case +/* Returns 0 if module did not declare VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD, in which case * diskless async loading should be avoided because module doesn't know there can be traffic during * database full resynchronization. */ int moduleAllModulesHandleReplAsyncLoad(void) { @@ -7092,8 +7093,8 @@ int moduleAllModulesHandleReplAsyncLoad(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); - if (!(module->options & REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD)) { + struct ValkeyModule *module = dictGetVal(de); + if (!(module->options & VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD)) { dictReleaseIterator(di); return 0; } @@ -7103,13 +7104,13 @@ 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) { + * for `Load*` APIs the VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS flag must be set with + * ValkeyModule_SetModuleOptions first. */ +int VM_IsIOError(ValkeyModuleIO *io) { return io->error; } -static int flushRedisModuleIOBuffer(RedisModuleIO *io) { +static int flushRedisModuleIOBuffer(ValkeyModuleIO *io) { if (!io->pre_flush_buffer) return 0; /* We have data that must be flushed before saving the current data. @@ -7125,7 +7126,7 @@ 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 VM_SaveUnsigned(ValkeyModuleIO *io, uint64_t value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7145,7 +7146,7 @@ void RM_SaveUnsigned(RedisModuleIO *io, uint64_t value) { /* 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 VM_LoadUnsigned(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_UINT) goto loaderr; @@ -7159,27 +7160,27 @@ uint64_t RM_LoadUnsigned(RedisModuleIO *io) { return 0; } -/* Like RedisModule_SaveUnsigned() but for signed 64 bit values. */ -void RM_SaveSigned(RedisModuleIO *io, int64_t value) { +/* Like ValkeyModule_SaveUnsigned() but for signed 64 bit values. */ +void VM_SaveSigned(ValkeyModuleIO *io, int64_t value) { union {uint64_t u; int64_t i;} conv; conv.i = value; - RM_SaveUnsigned(io,conv.u); + VM_SaveUnsigned(io,conv.u); } -/* Like RedisModule_LoadUnsigned() but for signed 64 bit values. */ -int64_t RM_LoadSigned(RedisModuleIO *io) { +/* Like ValkeyModule_LoadUnsigned() but for signed 64 bit values. */ +int64_t VM_LoadSigned(ValkeyModuleIO *io) { union {uint64_t u; int64_t i;} conv; - conv.u = RM_LoadUnsigned(io); + conv.u = VM_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 ValkeyModuleString. * - * The string can be later loaded with RedisModule_LoadString() or + * The string can be later loaded with ValkeyModule_LoadString() or * other Load family functions expecting a serialized string inside * the RDB file. */ -void RM_SaveString(RedisModuleIO *io, RedisModuleString *s) { +void VM_SaveString(ValkeyModuleIO *io, ValkeyModuleString *s) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7196,9 +7197,9 @@ void RM_SaveString(RedisModuleIO *io, RedisModuleString *s) { io->error = 1; } -/* Like RedisModule_SaveString() but takes a raw C pointer and length +/* Like ValkeyModule_SaveString() but takes a raw C pointer and length * as input. */ -void RM_SaveStringBuffer(RedisModuleIO *io, const char *str, size_t len) { +void VM_SaveStringBuffer(ValkeyModuleIO *io, const char *str, size_t len) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7215,8 +7216,8 @@ void RM_SaveStringBuffer(RedisModuleIO *io, const char *str, size_t len) { io->error = 1; } -/* Implements RM_LoadString() and RM_LoadStringBuffer() */ -void *moduleLoadString(RedisModuleIO *io, int plain, size_t *lenptr) { +/* Implements VM_LoadString() and VM_LoadStringBuffer() */ +void *moduleLoadString(ValkeyModuleIO *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; @@ -7231,33 +7232,33 @@ void *moduleLoadString(RedisModuleIO *io, int plain, size_t *lenptr) { } /* 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 ValkeyModule_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 ValkeyModuleString object, and + * the user should at some point free it with a call to ValkeyModule_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 ValkeyModuleString objects, + * the similar function ValkeyModule_LoadStringBuffer() could be used instead. */ +ValkeyModuleString *VM_LoadString(ValkeyModuleIO *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 ValkeyModule_LoadString() but returns a heap allocated string that + * was allocated with ValkeyModule_Alloc(), and can be resized or freed with + * ValkeyModule_Realloc() or ValkeyModule_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 *VM_LoadStringBuffer(ValkeyModuleIO *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 ValkeyModule_LoadDouble(). */ +void VM_SaveDouble(ValkeyModuleIO *io, double value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7275,8 +7276,8 @@ void RM_SaveDouble(RedisModuleIO *io, double value) { } /* 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 ValkeyModule_SaveDouble(). */ +double VM_LoadDouble(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_DOUBLE) goto loaderr; @@ -7292,8 +7293,8 @@ double RM_LoadDouble(RedisModuleIO *io) { /* 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 ValkeyModule_LoadFloat(). */ +void VM_SaveFloat(ValkeyModuleIO *io, float value) { if (io->error) return; if (flushRedisModuleIOBuffer(io) == -1) goto saveerr; /* Save opcode. */ @@ -7311,8 +7312,8 @@ void RM_SaveFloat(RedisModuleIO *io, float value) { } /* 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 ValkeyModule_SaveFloat(). */ +float VM_LoadFloat(ValkeyModuleIO *io) { if (io->error) return 0; uint64_t opcode = rdbLoadLen(io->rio,NULL); if (opcode != RDB_MODULE_OPCODE_FLOAT) goto loaderr; @@ -7328,26 +7329,26 @@ float RM_LoadFloat(RedisModuleIO *io) { /* 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 ValkeyModule_LoadLongDouble(). */ +void VM_SaveLongDouble(ValkeyModuleIO *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 * save it as a string type. */ size_t len = ld2string(buf,sizeof(buf),value,LD_STR_HEX); - RM_SaveStringBuffer(io,buf,len); + VM_SaveStringBuffer(io,buf,len); } /* 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 ValkeyModule_SaveLongDouble(). */ +long double VM_LoadLongDouble(ValkeyModuleIO *io) { if (io->error) return 0; long double value; size_t len; - char* str = RM_LoadStringBuffer(io,&len); + char* str = VM_LoadStringBuffer(io,&len); if (!str) return 0; string2ld(str,len,&value); - RM_Free(str); + VM_Free(str); return value; } @@ -7359,7 +7360,7 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); listIter li; listNode *ln; @@ -7388,7 +7389,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 + * `ValkeyModule_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. @@ -7423,20 +7424,20 @@ ssize_t rdbSaveModulesAux(rio *rdb, int when) { * EndSequence(); * */ -void RM_DigestAddStringBuffer(RedisModuleDigest *md, const char *ele, size_t len) { +void VM_DigestAddStringBuffer(ValkeyModuleDigest *md, const char *ele, size_t len) { mixDigest(md->o,ele,len); } -/* Like `RedisModule_DigestAddStringBuffer()` but takes a `long long` as input +/* Like `ValkeyModule_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 VM_DigestAddLongLong(ValkeyModuleDigest *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 `ValkeyModule_DigestAddElement()`. */ +void VM_DigestEndSequence(ValkeyModuleDigest *md) { xorDigest(md->x,md->o,sizeof(md->o)); memset(md->o,0,sizeof(md->o)); } @@ -7448,22 +7449,22 @@ void RM_DigestEndSequence(RedisModuleDigest *md) { * implement in order to allow a module to arbitrarily serialize/de-serialize * keys, similar to how the Redis 'DUMP' and 'RESTORE' commands are implemented. * - * Modules should generally use the REDISMODULE_OPTIONS_HANDLE_IO_ERRORS flag and + * Modules should generally use the VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS flag and * make sure the de-serialization code properly checks and handles IO errors * (freeing allocated buffers and returning a NULL). * * 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 *VM_LoadDataTypeFromStringEncver(const ValkeyModuleString *str, const moduleType *mt, int encver) { rio payload; - RedisModuleIO io; + ValkeyModuleIO io; void *ret; rioInitWithBuffer(&payload, str->ptr); moduleInitIOContext(io,(moduleType *)mt,&payload,NULL,-1); - /* All RM_Save*() calls always write a version 2 compatible format, so we + /* All VM_Save*() calls always write a version 2 compatible format, so we * need to make sure we read the same. */ ret = mt->rdb_load(&io,encver); @@ -7474,23 +7475,23 @@ void *RM_LoadDataTypeFromStringEncver(const RedisModuleString *str, const module return ret; } -/* Similar to RM_LoadDataTypeFromStringEncver, original version of the API, kept +/* Similar to VM_LoadDataTypeFromStringEncver, original version of the API, kept * for backward compatibility. */ -void *RM_LoadDataTypeFromString(const RedisModuleString *str, const moduleType *mt) { - return RM_LoadDataTypeFromStringEncver(str, mt, 0); +void *VM_LoadDataTypeFromString(const ValkeyModuleString *str, const moduleType *mt) { + return VM_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 ValkeyModuleString. * * 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) { +ValkeyModuleString *VM_SaveDataTypeToString(ValkeyModuleCtx *ctx, void *data, const moduleType *mt) { rio payload; - RedisModuleIO io; + ValkeyModuleIO io; rioInitWithBuffer(&payload,sdsempty()); moduleInitIOContext(io,(moduleType *)mt,&payload,NULL,-1); @@ -7503,18 +7504,18 @@ RedisModuleString *RM_SaveDataTypeToString(RedisModuleCtx *ctx, void *data, cons return NULL; } else { robj *str = createObject(OBJ_STRING,payload.io.buffer.ptr); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,str); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_STRING,str); return str; } } /* Returns the name of the key currently being processed. */ -const RedisModuleString *RM_GetKeyNameFromDigest(RedisModuleDigest *dig) { +const ValkeyModuleString *VM_GetKeyNameFromDigest(ValkeyModuleDigest *dig) { return dig->key; } /* Returns the database id of the key currently being processed. */ -int RM_GetDbIdFromDigest(RedisModuleDigest *dig) { +int VM_GetDbIdFromDigest(ValkeyModuleDigest *dig) { return dig->dbid; } /* -------------------------------------------------------------------------- @@ -7523,10 +7524,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 ValkeyModule_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 VM_EmitAOF(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) { if (io->error) return; struct serverCommand *cmd; robj **argv = NULL; @@ -7551,7 +7552,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 ValkeyModule_EmitAOF() with wrong format specifiers '%s'", io->type->name, fmt); io->error = 1; errno = EINVAL; @@ -7576,34 +7577,34 @@ void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) { * ## IO context handling * -------------------------------------------------------------------------- */ -RedisModuleCtx *RM_GetContextFromIO(RedisModuleIO *io) { +ValkeyModuleCtx *VM_GetContextFromIO(ValkeyModuleIO *io) { if (io->ctx) return io->ctx; /* Can't have more than one... */ - io->ctx = zmalloc(sizeof(RedisModuleCtx)); - moduleCreateContext(io->ctx, io->type->module, REDISMODULE_CTX_NONE); + io->ctx = zmalloc(sizeof(ValkeyModuleCtx)); + moduleCreateContext(io->ctx, io->type->module, VALKEYMODULE_CTX_NONE); return io->ctx; } /* 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 ValkeyModuleString *VM_GetKeyNameFromIO(ValkeyModuleIO *io) { return io->key; } -/* Returns a RedisModuleString with the name of the key from RedisModuleKey. */ -const RedisModuleString *RM_GetKeyNameFromModuleKey(RedisModuleKey *key) { +/* Returns a ValkeyModuleString with the name of the key from ValkeyModuleKey. */ +const ValkeyModuleString *VM_GetKeyNameFromModuleKey(ValkeyModuleKey *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 ValkeyModuleKey. */ +int VM_GetDbIdFromModuleKey(ValkeyModuleKey *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 VM_GetDbIdFromIO(ValkeyModuleIO *io) { return io->dbid; } @@ -7613,11 +7614,11 @@ int RM_GetDbIdFromIO(RedisModuleIO *io) { /* This is the low level function implementing both: * - * RM_Log() - * RM_LogIOError() + * VM_Log() + * VM_LogIOError() * */ -void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va_list ap) { +void moduleLogRaw(ValkeyModule *module, const char *levelstr, const char *fmt, va_list ap) { char msg[LOG_MAX_LEN]; size_t name_len; int level; @@ -7639,10 +7640,10 @@ void moduleLogRaw(RedisModule *module, const char *levelstr, const char *fmt, va * printf-alike specifiers, while level is a string describing the log * level to use when emitting the log, and must be one of the following: * - * * "debug" (`REDISMODULE_LOGLEVEL_DEBUG`) - * * "verbose" (`REDISMODULE_LOGLEVEL_VERBOSE`) - * * "notice" (`REDISMODULE_LOGLEVEL_NOTICE`) - * * "warning" (`REDISMODULE_LOGLEVEL_WARNING`) + * * "debug" (`VALKEYMODULE_LOGLEVEL_DEBUG`) + * * "verbose" (`VALKEYMODULE_LOGLEVEL_VERBOSE`) + * * "notice" (`VALKEYMODULE_LOGLEVEL_NOTICE`) + * * "warning" (`VALKEYMODULE_LOGLEVEL_WARNING`) * * If the specified log level is invalid, verbose is used by default. * There is a fixed limit to the length of the log line this function is able @@ -7653,7 +7654,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 VM_Log(ValkeyModuleCtx *ctx, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(ctx? ctx->module: NULL,levelstr,fmt,ap); @@ -7665,7 +7666,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 VM_LogIOError(ValkeyModuleIO *io, const char *levelstr, const char *fmt, ...) { va_list ap; va_start(ap, fmt); moduleLogRaw(io->type->module,levelstr,fmt,ap); @@ -7674,20 +7675,20 @@ 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 `ValkeyModule_Assert(expression)` is recommended, rather than * calling this function directly. * * A failed assertion will shut down the server and produce logging information * that looks identical to information generated by Redis itself. */ -void RM__Assert(const char *estr, const char *file, int line) { +void VM__Assert(const char *estr, const char *file, int line) { _serverAssert(estr, file, line); } /* Allows adding event to the latency monitor to be observed by the LATENCY * command. The call is skipped if the latency is smaller than the configured * latency-monitor-threshold. */ -void RM_LatencyAddSample(const char *event, mstime_t latency) { +void VM_LatencyAddSample(const char *event, mstime_t latency) { if (latency >= server.latency_monitor_threshold) latencyAddSample(event, latency); } @@ -7701,7 +7702,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; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; return bc->unblocked == 1; } @@ -7716,18 +7717,18 @@ 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 ValkeyModuleBlockedClient 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; + ValkeyModuleBlockedClient *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; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_NONE); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_NONE); ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; bc->disconnect_callback(&ctx,bc); @@ -7736,19 +7737,19 @@ void unblockClientFromModule(client *c) { /* If we made it here and client is still blocked it means that the command * timed-out, client was killed or disconnected and disconnect_callback was - * not implemented (or it was, but RM_UnblockClient was not called from + * not implemented (or it was, but VM_UnblockClient was not called from * within it, as it should). * We must call moduleUnblockClient in order to free privdata and - * RedisModuleBlockedClient. + * ValkeyModuleBlockedClient. * * 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 + * the contract is that the module should not call VM_UnblockClient under * normal circumstances. * Clients implementing threads and working with private data should be - * aware that calling RM_UnblockClient for every blocked client is their + * aware that calling VM_UnblockClient for every blocked client is their * responsibility, and if they fail to do so memory may leak. Ideally they * should implement the disconnect and timeout callbacks and call - * RM_UnblockClient, but any other way is also acceptable. */ + * VM_UnblockClient, but any other way is also acceptable. */ if (bc->blocked_on_keys && !bc->unblocked) moduleUnblockClient(c); @@ -7756,36 +7757,36 @@ void unblockClientFromModule(client *c) { } /* Block a client in the context of a module: this function implements both - * RM_BlockClient() and RM_BlockClientOnKeys() depending on the fact the + * VM_BlockClient() and VM_BlockClientOnKeys() depending on the fact the * keys are passed or not. * * When not blocking for keys, the keys, numkeys, and privdata parameters are * not needed. The privdata in that case must be NULL, since later is - * RM_UnblockClient() that will provide some private data that the reply + * VM_UnblockClient() that will provide some private data that the reply * callback will receive. * - * Instead when blocking for keys, normally RM_UnblockClient() will not be + * Instead when blocking for keys, normally VM_UnblockClient() will not be * called (because the client will unblock when the key is modified), so * 'privdata' should be provided in that case, so that once the client is * unlocked and the reply callback is called, it will receive its associated * private data. * - * Even when blocking on keys, RM_UnblockClient() can be called however, but + * Even when blocking on keys, VM_UnblockClient() can be called however, but * in that case the privdata argument is disregarded, because we pass the * 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, +ValkeyModuleBlockedClient *moduleBlockClient(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleAuthCallback auth_reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **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(ValkeyModuleBlockedClient)); + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; ctx->module->blocked_clients++; /* We need to handle the invalid operation of calling modules blocking @@ -7797,7 +7798,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF bc->reply_callback = reply_callback; bc->auth_reply_cb = auth_reply_callback; bc->timeout_callback = timeout_callback; - bc->disconnect_callback = NULL; /* Set by RM_SetDisconnectCallback() */ + bc->disconnect_callback = NULL; /* Set by VM_SetDisconnectCallback() */ bc->free_privdata = free_privdata; bc->privdata = privdata; bc->reply_client = moduleAllocTempClient(); @@ -7826,7 +7827,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF addReplyError(c, islua ? "Blocking module command called from Lua script" : "Blocking module command called from transaction"); - } else if (ctx->flags & REDISMODULE_CTX_BLOCKED_REPLY) { + } else if (ctx->flags & VALKEYMODULE_CTX_BLOCKED_REPLY) { c->bstate.module_blocked_handle = NULL; addReplyError(c, "Blocking module command called from a Reply callback context"); } else if (!auth_reply_callback && clientHasModuleAuthInProgress(c)) { @@ -7834,7 +7835,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF addReplyError(c, "Clients undergoing module based authentication can only be blocked on auth"); } else { if (keys) { - blockForKeys(c,BLOCKED_MODULE,keys,numkeys,timeout,flags&REDISMODULE_BLOCK_UNBLOCK_DELETED); + blockForKeys(c,BLOCKED_MODULE,keys,numkeys,timeout,flags&VALKEYMODULE_BLOCK_UNBLOCK_DELETED); } else { c->bstate.timeout = timeout; blockClient(c,BLOCKED_MODULE); @@ -7850,17 +7851,17 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF * (with AUTH field provided) commands are called. * The callbacks will be called with a module context along with a username and a password, and are * expected to take one of the following actions: - * (1) Authenticate - Use the RM_AuthenticateClient* API and return REDISMODULE_AUTH_HANDLED. + * (1) Authenticate - Use the VM_AuthenticateClient* API and return VALKEYMODULE_AUTH_HANDLED. * This will immediately end the auth chain as successful and add the OK reply. - * (2) Deny Authentication - Return REDISMODULE_AUTH_HANDLED without authenticating or blocking the + * (2) Deny Authentication - Return VALKEYMODULE_AUTH_HANDLED without authenticating or blocking the * client. Optionally, `err` can be set to a custom error message and `err` will be automatically * freed by the server. * This will immediately end the auth chain as unsuccessful and add the ERR reply. - * (3) Block a client on authentication - Use the RM_BlockClientOnAuth API and return - * REDISMODULE_AUTH_HANDLED. Here, the client will be blocked until the RM_UnblockClient API is used - * which will trigger the auth reply callback (provided through the RM_BlockClientOnAuth). + * (3) Block a client on authentication - Use the VM_BlockClientOnAuth API and return + * VALKEYMODULE_AUTH_HANDLED. Here, the client will be blocked until the VM_UnblockClient API is used + * which will trigger the auth reply callback (provided through the VM_BlockClientOnAuth). * In this reply callback, the Module should authenticate, deny or skip handling authentication. - * (4) Skip handling Authentication - Return REDISMODULE_AUTH_NOT_HANDLED without blocking the + * (4) Skip handling Authentication - Return VALKEYMODULE_AUTH_NOT_HANDLED without blocking the * client. This will allow the engine to attempt the next module auth callback. * If none of the callbacks authenticate or deny auth, then password based auth is attempted and * will authenticate or add failure logs and reply to the clients accordingly. @@ -7870,44 +7871,44 @@ 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(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *password, ValkeyModuleString **err) { + * const char *user = ValkeyModule_StringPtrLen(username, NULL); + * const char *pwd = ValkeyModule_StringPtrLen(password, NULL); * if (!strcmp(user,"foo") && !strcmp(pwd,"valid_password")) { - * RedisModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); - * return REDISMODULE_AUTH_HANDLED; + * ValkeyModule_AuthenticateClientWithACLUser(ctx, "foo", 3, NULL, NULL, NULL); + * return VALKEYMODULE_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); + * ValkeyModuleString *log = ValkeyModule_CreateString(ctx, "Module Auth", 11); + * ValkeyModule_ACLAddLogEntryByUserName(ctx, username, log, VALKEYMODULE_ACL_LOG_AUTH); + * ValkeyModule_FreeString(ctx, log); * const char *err_msg = "Auth denied by Misc Module."; - * *err = RedisModule_CreateString(ctx, err_msg, strlen(err_msg)); - * return REDISMODULE_AUTH_HANDLED; + * *err = ValkeyModule_CreateString(ctx, err_msg, strlen(err_msg)); + * return VALKEYMODULE_AUTH_HANDLED; * } - * return REDISMODULE_AUTH_NOT_HANDLED; + * return VALKEYMODULE_AUTH_NOT_HANDLED; * } * - * int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - * if (RedisModule_Init(ctx,"authmodule",1,REDISMODULE_APIVER_1)== REDISMODULE_ERR) - * return REDISMODULE_ERR; - * RedisModule_RegisterAuthCallback(ctx, auth_cb); - * return REDISMODULE_OK; + * int ValkeyModule_OnLoad(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc) { + * if (ValkeyModule_Init(ctx,"authmodule",1,VALKEYMODULE_APIVER_1)== VALKEYMODULE_ERR) + * return VALKEYMODULE_ERR; + * ValkeyModule_RegisterAuthCallback(ctx, auth_cb); + * return VALKEYMODULE_OK; * } */ -void RM_RegisterAuthCallback(RedisModuleCtx *ctx, RedisModuleAuthCallback cb) { - RedisModuleAuthCtx *auth_ctx = zmalloc(sizeof(RedisModuleAuthCtx)); +void VM_RegisterAuthCallback(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback cb) { + ValkeyModuleAuthCtx *auth_ctx = zmalloc(sizeof(ValkeyModuleAuthCtx)); 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, ValkeyModuleBlockedClient *bc) { if (bc->privdata && bc->free_privdata) { - RedisModuleCtx ctx; - int ctx_flags = c == NULL ? REDISMODULE_CTX_BLOCKED_DISCONNECTED : REDISMODULE_CTX_NONE; + ValkeyModuleCtx ctx; + int ctx_flags = c == NULL ? VALKEYMODULE_CTX_BLOCKED_DISCONNECTED : VALKEYMODULE_CTX_NONE; moduleCreateContext(&ctx, bc->module, ctx_flags); ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; @@ -7917,12 +7918,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(ValkeyModule *module) { listIter li; listNode *ln; listRewind(moduleAuthCallbacks, &li); while ((ln = listNext(&li))) { - RedisModuleAuthCtx *ctx = listNodeValue(ln); + ValkeyModuleAuthCtx *ctx = listNodeValue(ln); if (ctx->module == module) { listDelNode(moduleAuthCallbacks, ln); zfree(ctx); @@ -7934,11 +7935,11 @@ 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; + ValkeyModuleAuthCtx *cur_auth_ctx = NULL; listNode *ln; listIter li; listRewind(moduleAuthCallbacks, &li); - int result = REDISMODULE_AUTH_NOT_HANDLED; + int result = VALKEYMODULE_AUTH_NOT_HANDLED; while((ln = listNext(&li))) { cur_auth_ctx = listNodeValue(ln); /* Skip over the previously attempted auth contexts. */ @@ -7948,32 +7949,32 @@ 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; - moduleCreateContext(&ctx, cur_auth_ctx->module, REDISMODULE_CTX_NONE); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, cur_auth_ctx->module, VALKEYMODULE_CTX_NONE); ctx.client = c; *err = NULL; c->module_auth_ctx = cur_auth_ctx; result = cur_auth_ctx->auth_cb(&ctx, username, password, err); moduleFreeContext(&ctx); - if (result == REDISMODULE_AUTH_HANDLED) break; + if (result == VALKEYMODULE_AUTH_HANDLED) break; /* If Auth was not handled (allowed/denied/blocked) by the Module, try the next auth cb. */ } return result; } /* Helper function to handle a reprocessed unblocked auth client. - * Returns REDISMODULE_AUTH_NOT_HANDLED if the client was not reprocessed after a blocking module + * Returns VALKEYMODULE_AUTH_NOT_HANDLED if the client was not reprocessed after a blocking module * auth operation. * Otherwise, we attempt the auth reply callback & the free priv data callback, update fields and * return the result of the reply callback. */ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, robj **err) { - int result = REDISMODULE_AUTH_NOT_HANDLED; + int result = VALKEYMODULE_AUTH_NOT_HANDLED; if (!c->module_blocked_client) return result; - RedisModuleBlockedClient *bc = (RedisModuleBlockedClient *) c->module_blocked_client; + ValkeyModuleBlockedClient *bc = (ValkeyModuleBlockedClient *) c->module_blocked_client; bc->client = c; if (bc->auth_reply_cb) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; ctx.client = bc->client; @@ -7990,7 +7991,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 ValkeyModule 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. @@ -8002,16 +8003,16 @@ int attemptBlockedAuthReplyCallback(client *c, robj *username, robj *password, r int checkModuleAuthentication(client *c, robj *username, robj *password, robj **err) { if (!listLength(moduleAuthCallbacks)) return AUTH_NOT_HANDLED; int result = attemptBlockedAuthReplyCallback(c, username, password, err); - if (result == REDISMODULE_AUTH_NOT_HANDLED) { + if (result == VALKEYMODULE_AUTH_NOT_HANDLED) { result = attemptNextAuthCb(c, username, password, err); } if (c->flags & CLIENT_BLOCKED) { - /* Modules are expected to return REDISMODULE_AUTH_HANDLED when blocking clients. */ - serverAssert(result == REDISMODULE_AUTH_HANDLED); + /* Modules are expected to return VALKEYMODULE_AUTH_HANDLED when blocking clients. */ + serverAssert(result == VALKEYMODULE_AUTH_HANDLED); return AUTH_BLOCKED; } c->module_auth_ctx = NULL; - if (result == REDISMODULE_AUTH_NOT_HANDLED) { + if (result == VALKEYMODULE_AUTH_NOT_HANDLED) { c->flags &= ~CLIENT_MODULE_AUTH_HAS_RESULT; return AUTH_NOT_HANDLED; } @@ -8025,26 +8026,26 @@ int checkModuleAuthentication(client *c, robj *username, robj *password, robj ** /* This function is called from module.c in order to check if a module * blocked for BLOCKED_MODULE and subtype 'on keys' (bc->blocked_on_keys true) * can really be unblocked, since the module was able to serve the client. - * If the callback returns REDISMODULE_OK, then the client can be unblocked, + * If the callback returns VALKEYMODULE_OK, then the client can be unblocked, * otherwise the client remains blocked and we'll retry again when one of * the keys it blocked for becomes "ready" again. * 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; + ValkeyModuleBlockedClient *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() + * in the unblocking list for any reason (including VM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return 0; - RedisModuleCtx ctx; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_ready_key = key; ctx.blocked_privdata = bc->privdata; ctx.client = bc->client; ctx.blocked_client = bc; - if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == REDISMODULE_OK) + if (bc->reply_callback(&ctx,(void**)c->argv,c->argc) == VALKEYMODULE_OK) served = 1; moduleFreeContext(&ctx); return served; @@ -8052,30 +8053,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 + * ValkeyModule_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 ValkeyModule_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 ValkeyModule_UnblockClient() call. * - * Note: RedisModule_UnblockClient should be called for every blocked client, + * Note: ValkeyModule_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 ValkeyModule_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 ValkeyModule_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 @@ -8086,26 +8087,26 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { * * Measuring background time: By default the time spent in the blocked command * is not account for the total command duration. To include such time you should - * use RM_BlockedClientMeasureTimeStart() and RM_BlockedClientMeasureTimeEnd() one, + * use VM_BlockedClientMeasureTimeStart() and VM_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*), +ValkeyModuleBlockedClient *VM_BlockClient(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms) { return moduleBlockClient(ctx,reply_callback,NULL,timeout_callback,free_privdata,timeout_ms, NULL,0,NULL,0); } /* Block the current client for module authentication in the background. If module auth is not in - * 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. + * progress on the client, the API returns NULL. Otherwise, the client is blocked and the VM_BlockedClient + * is returned similar to the VM_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*)) { +ValkeyModuleBlockedClient *VM_BlockClientOnAuth(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback reply_callback, + void (*free_privdata)(ValkeyModuleCtx*,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); + ValkeyModuleBlockedClient *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; } @@ -8113,16 +8114,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 *VM_BlockClientGetPrivateData(ValkeyModuleBlockedClient *blocked_client) { return blocked_client->privdata; } /* Set private data on a blocked client */ -void RM_BlockClientSetPrivateData(RedisModuleBlockedClient *blocked_client, void *private_data) { +void VM_BlockClientSetPrivateData(ValkeyModuleBlockedClient *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 ValkeyModule_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. * @@ -8140,31 +8141,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(). + * ValkeyModule_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 - * 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 + * ValkeyModule_BlockClientOnKeys() the reply callback is not called after + * VM_UnblockClient() is called, but every time a key is signaled as ready: + * if the reply callback can serve the client, it returns VALKEYMODULE_OK + * and the client is unblocked, otherwise it will return VALKEYMODULE_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 ValkeyModule_GetBlockedClientReadyKey(), that returns + * just the string name of the key as a ValkeyModuleString 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 ValkeyModule_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 + * ValkeyModule_BlockClient() the private data to reply to the client is + * passed when calling ValkeyModule_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 @@ -8173,44 +8174,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 ValkeyModule_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 ValkeyModule_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) { +ValkeyModuleBlockedClient *VM_BlockClientOnKeys(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **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 - * Can be either REDISMODULE_BLOCK_UNBLOCK_DEFAULT, which means default behavior (same - * as calling RedisModule_BlockClientOnKeys) +/* Same as ValkeyModule_BlockClientOnKeys, but can take VALKEYMODULE_BLOCK_* flags + * Can be either VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT, which means default behavior (same + * as calling ValkeyModule_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. + * - `VALKEYMODULE_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, +ValkeyModuleBlockedClient *VM_BlockClientOnKeysWithFlags(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, + ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), + long long timeout_ms, ValkeyModuleString **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 ValkeyModule_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 VM_SignalKeyAsReady(ValkeyModuleCtx *ctx, ValkeyModuleString *key) { signalKeyAsReady(ctx->client->db, key, OBJ_MODULE); } -/* Implements RM_UnblockClient() and moduleUnblockClient(). */ -int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { +/* Implements VM_UnblockClient() and moduleUnblockClient(). */ +int moduleUnblockClientByHandle(ValkeyModuleBlockedClient *bc, void *privdata) { pthread_mutex_lock(&moduleUnblockedClientsMutex); if (!bc->blocked_on_keys) bc->privdata = privdata; bc->unblocked = 1; @@ -8221,24 +8222,24 @@ int moduleUnblockClientByHandle(RedisModuleBlockedClient *bc, void *privdata) { } listAddNodeTail(moduleUnblockedClients,bc); pthread_mutex_unlock(&moduleUnblockedClientsMutex); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; moduleUnblockClientByHandle(bc,NULL); } /* Return true if the client 'c' was blocked by a module using - * RM_BlockClientOnKeys(). */ + * VM_BlockClientOnKeys(). */ int moduleClientIsBlockedOnKeys(client *c) { - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *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 `ValkeyModule_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 @@ -8251,38 +8252,38 @@ 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. + * ValkeyModule_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 - * callback via RM_GetBlockedClientPrivateData). */ -int RM_UnblockClient(RedisModuleBlockedClient *bc, void *privdata) { + * ValkeyModule_BlockClientOnKeys() is accessible from the timeout + * callback via VM_GetBlockedClientPrivateData). */ +int VM_UnblockClient(ValkeyModuleBlockedClient *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. */ - if (bc->timeout_callback == NULL) return REDISMODULE_ERR; - if (bc->unblocked) return REDISMODULE_OK; + if (bc->timeout_callback == NULL) return VALKEYMODULE_ERR; + if (bc->unblocked) return VALKEYMODULE_OK; if (bc->client) moduleBlockedClientTimedOut(bc->client, 1); } moduleUnblockClientByHandle(bc,privdata); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Abort a blocked client blocking operation: the client will be unblocked * without firing any callback. */ -int RM_AbortBlock(RedisModuleBlockedClient *bc) { +int VM_AbortBlock(ValkeyModuleBlockedClient *bc) { bc->reply_callback = NULL; bc->disconnect_callback = NULL; bc->auth_reply_cb = NULL; - return RM_UnblockClient(bc,NULL); + return VM_UnblockClient(bc,NULL); } /* 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 ValkeyModule_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 ValkeyModule_UnblockClient() safely, otherwise * the client will remain blocked forever if the timeout is large. * * Notes: @@ -8294,21 +8295,21 @@ 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 VM_SetDisconnectCallback(ValkeyModuleBlockedClient *bc, ValkeyModuleDisconnectFunc callback) { bc->disconnect_callback = callback; } /* This function will check the moduleUnblockedClients queue in order to * call the reply callback and really unblock the client. * - * Clients end into this list because of calls to RM_UnblockClient(), + * Clients end into this list because of calls to VM_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 ValkeyModuleBlockedClient structure in the queue * will have the 'client' field set to NULL. */ void moduleHandleBlockedClients(void) { listNode *ln; - RedisModuleBlockedClient *bc; + ValkeyModuleBlockedClient *bc; pthread_mutex_lock(&moduleUnblockedClientsMutex); while (listLength(moduleUnblockedClients)) { @@ -8323,14 +8324,14 @@ void moduleHandleBlockedClients(void) { /* Call the reply callback if the client is valid and we have * any callback. However the callback is not called if the client - * was blocked on keys (RM_BlockClientOnKeys()), because we already + * was blocked on keys (VM_BlockClientOnKeys()), because we already * called such callback in moduleTryServeClientBlockedOnKey() when * the key was signaled as ready. */ 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; - moduleCreateContext(&ctx, bc->module, REDISMODULE_CTX_BLOCKED_REPLY); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, bc->module, VALKEYMODULE_CTX_BLOCKED_REPLY); ctx.blocked_privdata = bc->privdata; ctx.blocked_ready_key = NULL; ctx.client = bc->client; @@ -8411,7 +8412,7 @@ int moduleBlockedClientMayTimeout(client *c) { if (c->bstate.btype != BLOCKED_MODULE) return 1; - RedisModuleBlockedClient *bc = c->bstate.module_blocked_handle; + ValkeyModuleBlockedClient *bc = c->bstate.module_blocked_handle; return (bc && bc->timeout_callback != NULL); } @@ -8427,16 +8428,16 @@ 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; + ValkeyModuleBlockedClient *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() + * in the unblocking list for any reason (including VM_UnblockClient() * explicit call). See #6798. */ if (bc->unblocked) return; - RedisModuleCtx ctx; - int flags = REDISMODULE_CTX_BLOCKED_TIMEOUT; - if (from_module) flags |= REDISMODULE_CTX_THREAD_SAFE; + ValkeyModuleCtx ctx; + int flags = VALKEYMODULE_CTX_BLOCKED_TIMEOUT; + if (from_module) flags |= VALKEYMODULE_CTX_THREAD_SAFE; moduleCreateContext(&ctx, bc->module, flags); ctx.client = bc->client; ctx.blocked_client = bc; @@ -8465,24 +8466,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) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_REPLY) != 0; +int VM_IsBlockedReplyRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_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) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_TIMEOUT) != 0; +int VM_IsBlockedTimeoutRequest(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_BLOCKED_TIMEOUT) != 0; } -/* Get the private data set by RedisModule_UnblockClient() */ -void *RM_GetBlockedClientPrivateData(RedisModuleCtx *ctx) { +/* Get the private data set by ValkeyModule_UnblockClient() */ +void *VM_GetBlockedClientPrivateData(ValkeyModuleCtx *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 ValkeyModule_BlockClientOnKeys(). */ +ValkeyModuleString *VM_GetBlockedClientReadyKey(ValkeyModuleCtx *ctx) { return ctx->blocked_ready_key; } @@ -8490,15 +8491,15 @@ 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) { +ValkeyModuleBlockedClient *VM_GetBlockedClientHandle(ValkeyModuleCtx *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) { - return (ctx->flags & REDISMODULE_CTX_BLOCKED_DISCONNECTED) != 0; +int VM_BlockedClientDisconnected(ValkeyModuleCtx *ctx) { + return (ctx->flags & VALKEYMODULE_CTX_BLOCKED_DISCONNECTED) != 0; } /* -------------------------------------------------------------------------- @@ -8508,27 +8509,27 @@ 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 + * `ValkeyModule_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); + * ValkeyModule_ThreadSafeContextLock(ctx); * ... make your call here ... - * RedisModule_ThreadSafeContextUnlock(ctx); + * ValkeyModule_ThreadSafeContextUnlock(ctx); * - * This is not needed when using `RedisModule_Reply*` functions, assuming + * This is not needed when using `ValkeyModule_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 ValkeyModule_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 + * consider using `VM_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; - int flags = REDISMODULE_CTX_THREAD_SAFE; +ValkeyModuleCtx *VM_GetThreadSafeContext(ValkeyModuleBlockedClient *bc) { + ValkeyModuleCtx *ctx = zmalloc(sizeof(*ctx)); + ValkeyModule *module = bc ? bc->module : NULL; + int flags = VALKEYMODULE_CTX_THREAD_SAFE; /* Creating a new client object is costly. To avoid that, we have an * internal pool of client objects. In blockClient(), a client object is @@ -8540,7 +8541,7 @@ RedisModuleCtx *RM_GetThreadSafeContext(RedisModuleBlockedClient *bc) { * Assuming creating detached context is rare and not that performance * critical, we avoid synchronizing access to the client pool by creating * a new client */ - if (!bc) flags |= REDISMODULE_CTX_NEW_CLIENT; + if (!bc) flags |= VALKEYMODULE_CTX_NEW_CLIENT; moduleCreateContext(ctx, module, flags); /* Even when the context is associated with a blocked client, we can't * access it safely from another thread, so we use a fake client here @@ -8563,17 +8564,17 @@ 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)); +ValkeyModuleCtx *VM_GetDetachedThreadSafeContext(ValkeyModuleCtx *ctx) { + ValkeyModuleCtx *new_ctx = zmalloc(sizeof(*new_ctx)); /* We create a new client object for the detached context. - * See RM_GetThreadSafeContext() for more information */ + * See VM_GetThreadSafeContext() for more information */ moduleCreateContext(new_ctx, ctx->module, - REDISMODULE_CTX_THREAD_SAFE|REDISMODULE_CTX_NEW_CLIENT); + VALKEYMODULE_CTX_THREAD_SAFE|VALKEYMODULE_CTX_NEW_CLIENT); return new_ctx; } /* Release a thread safe context. */ -void RM_FreeThreadSafeContext(RedisModuleCtx *ctx) { +void VM_FreeThreadSafeContext(ValkeyModuleCtx *ctx) { moduleFreeContext(ctx); zfree(ctx); } @@ -8583,35 +8584,35 @@ void moduleGILAfterLock(void) { * code block which already opened a context. */ serverAssert(server.execution_nesting == 0); /* Bump up the nesting level to prevent immediate propagation - * of possible RM_Call from th thread */ + * of possible VM_Call from th thread */ enterExecutionUnit(1, 0); } /* 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 `ValkeyModule_Reply*` calls when there is * a blocked client connected to the thread safe context. */ -void RM_ThreadSafeContextLock(RedisModuleCtx *ctx) { +void VM_ThreadSafeContextLock(ValkeyModuleCtx *ctx) { UNUSED(ctx); moduleAcquireGIL(); moduleGILAfterLock(); } -/* Similar to RM_ThreadSafeContextLock but this function +/* Similar to VM_ThreadSafeContextLock but this function * would not block if the server lock is already acquired. * - * If successful (lock acquired) REDISMODULE_OK is returned, - * otherwise REDISMODULE_ERR is returned and errno is set + * If successful (lock acquired) VALKEYMODULE_OK is returned, + * otherwise VALKEYMODULE_ERR is returned and errno is set * accordingly. */ -int RM_ThreadSafeContextTryLock(RedisModuleCtx *ctx) { +int VM_ThreadSafeContextTryLock(ValkeyModuleCtx *ctx) { UNUSED(ctx); int res = moduleTryAcquireGIL(); if(res != 0) { errno = res; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } moduleGILAfterLock(); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void moduleGILBeforeUnlock(void) { @@ -8627,7 +8628,7 @@ void moduleGILBeforeUnlock(void) { } /* Release the server lock after a thread safe API call was executed. */ -void RM_ThreadSafeContextUnlock(RedisModuleCtx *ctx) { +void VM_ThreadSafeContextUnlock(ValkeyModuleCtx *ctx) { UNUSED(ctx); moduleGILBeforeUnlock(); moduleReleaseGIL(); @@ -8658,32 +8659,32 @@ 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 ValkeyModule_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: * - * - REDISMODULE_NOTIFY_GENERIC: Generic commands like DEL, EXPIRE, RENAME - * - REDISMODULE_NOTIFY_STRING: String events - * - REDISMODULE_NOTIFY_LIST: List events - * - REDISMODULE_NOTIFY_SET: Set events - * - REDISMODULE_NOTIFY_HASH: Hash events - * - REDISMODULE_NOTIFY_ZSET: Sorted Set events - * - REDISMODULE_NOTIFY_EXPIRED: Expiration events - * - REDISMODULE_NOTIFY_EVICTED: Eviction events - * - REDISMODULE_NOTIFY_STREAM: Stream events - * - REDISMODULE_NOTIFY_MODULE: Module types events - * - REDISMODULE_NOTIFY_KEYMISS: Key-miss events + * - VALKEYMODULE_NOTIFY_GENERIC: Generic commands like DEL, EXPIRE, RENAME + * - VALKEYMODULE_NOTIFY_STRING: String events + * - VALKEYMODULE_NOTIFY_LIST: List events + * - VALKEYMODULE_NOTIFY_SET: Set events + * - VALKEYMODULE_NOTIFY_HASH: Hash events + * - VALKEYMODULE_NOTIFY_ZSET: Sorted Set events + * - VALKEYMODULE_NOTIFY_EXPIRED: Expiration events + * - VALKEYMODULE_NOTIFY_EVICTED: Eviction events + * - VALKEYMODULE_NOTIFY_STREAM: Stream events + * - VALKEYMODULE_NOTIFY_MODULE: Module types events + * - VALKEYMODULE_NOTIFY_KEYMISS: Key-miss events * Notice, key-miss event is the only type * of event that is fired from within a read command. - * Performing RM_Call with a write command from within + * Performing VM_Call with a write command from within * this notification is wrong and discourage. It will * cause the read command that trigger the event to be * replicated to the AOF/Replica. - * - REDISMODULE_NOTIFY_ALL: All events (Excluding REDISMODULE_NOTIFY_KEYMISS) - * - REDISMODULE_NOTIFY_LOADED: A special notification available only for modules, + * - VALKEYMODULE_NOTIFY_ALL: All events (Excluding VALKEYMODULE_NOTIFY_KEYMISS) + * - VALKEYMODULE_NOTIFY_LOADED: A special notification available only for modules, * indicates that the key was loaded from persistence. * Notice, when this event fires, the given key - * can not be retained, use RM_CreateStringFromString + * can not be retained, use VM_CreateStringFromString * instead. * * We do not distinguish between key events and keyspace events, and it is up @@ -8691,9 +8692,9 @@ void moduleReleaseGIL(void) { * * The subscriber signature is: * - * int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, + * int (*ValkeyModuleNotificationFunc) (ValkeyModuleCtx *ctx, int type, * const char *event, - * RedisModuleString *key); + * ValkeyModuleString *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 @@ -8714,19 +8715,19 @@ void moduleReleaseGIL(void) { * that the notification code will be executed in the middle on Redis logic * (commands logic, eviction, expire). Changing the key space while the logic * runs is dangerous and discouraged. In order to react to key space events with - * write actions, please refer to `RM_AddPostNotificationJob`. + * write actions, please refer to `VM_AddPostNotificationJob`. * * See https://redis.io/topics/notifications for more information. */ -int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNotificationFunc callback) { - RedisModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); +int VM_SubscribeToKeyspaceEvents(ValkeyModuleCtx *ctx, int types, ValkeyModuleNotificationFunc callback) { + ValkeyModuleKeyspaceSubscriber *sub = zmalloc(sizeof(*sub)); sub->module = ctx->module; sub->event_mask = types; sub->notify_callback = callback; sub->active = 0; listAddNodeTail(moduleKeyspaceSubscribers, sub); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void firePostExecutionUnitJobs(void) { @@ -8738,11 +8739,11 @@ void firePostExecutionUnitJobs(void) { enterExecutionUnit(0, 0); while (listLength(modulePostExecUnitJobs) > 0) { listNode *ln = listFirst(modulePostExecUnitJobs); - RedisModulePostExecUnitJob *job = listNodeValue(ln); + ValkeyModulePostExecUnitJob *job = listNodeValue(ln); listDelNode(modulePostExecUnitJobs, ln); - RedisModuleCtx ctx; - moduleCreateContext(&ctx, job->module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, job->module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, job->dbid); job->callback(&ctx, job->pd); @@ -8755,8 +8756,8 @@ void firePostExecutionUnitJobs(void) { } /* When running inside a key space notification callback, it is dangerous and highly discouraged to perform any write - * operation (See `RM_SubscribeToKeyspaceEvents`). In order to still perform write actions in this scenario, - * Redis provides `RM_AddPostNotificationJob` API. The API allows to register a job callback which Redis will call + * operation (See `VM_SubscribeToKeyspaceEvents`). In order to still perform write actions in this scenario, + * Redis provides `VM_AddPostNotificationJob` API. The API allows to register a job callback which Redis will call * when the following condition are promised to be fulfilled: * 1. It is safe to perform any write operation. * 2. The job will be called atomically along side the key space notification. @@ -8769,13 +8770,13 @@ void firePostExecutionUnitJobs(void) { * * 'free_pd' can be NULL and in such case will not be used. * - * Return REDISMODULE_OK on success and REDISMODULE_ERR if was called while loading data from disk (AOF or RDB) or + * Return VALKEYMODULE_OK on success and VALKEYMODULE_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 VM_AddPostNotificationJob(ValkeyModuleCtx *ctx, ValkeyModulePostNotificationJobFunc callback, void *privdata, void (*free_privdata)(void*)) { if (server.loading|| (server.masterhost && server.repl_slave_ro)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModulePostExecUnitJob *job = zmalloc(sizeof(*job)); + ValkeyModulePostExecUnitJob *job = zmalloc(sizeof(*job)); job->module = ctx->module; job->callback = callback; job->pd = privdata; @@ -8783,21 +8784,21 @@ int RM_AddPostNotificationJob(RedisModuleCtx *ctx, RedisModulePostNotificationJo job->dbid = ctx->client->db->id; listAddNodeTail(modulePostExecUnitJobs, job); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get the configured bitmap of notify-keyspace-events (Could be used - * for additional filtering in RedisModuleNotificationFunc) */ -int RM_GetNotifyKeyspaceEvents(void) { + * for additional filtering in ValkeyModuleNotificationFunc) */ +int VM_GetNotifyKeyspaceEvents(void) { return server.notify_keyspace_events; } /* Expose notifyKeyspaceEvent to modules */ -int RM_NotifyKeyspaceEvent(RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key) { +int VM_NotifyKeyspaceEvent(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key) { if (!ctx || !ctx->client) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; notifyKeyspaceEvent(type, (char *)event, key, ctx->client->db->id); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Dispatcher for keyspace notifications to module subscriber functions. @@ -8809,7 +8810,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 ValkeyModules_AddPostNotificationJob instead. * * Anyway, we want any propagated commands from within notify_callback * to be propagated inside a MULTI/EXEC together with the original @@ -8834,13 +8835,13 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) type &= ~(NOTIFY_KEYEVENT | NOTIFY_KEYSPACE); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + ValkeyModuleKeyspaceSubscriber *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; - moduleCreateContext(&ctx, sub->module, REDISMODULE_CTX_TEMP_CLIENT); + (sub->active == 0 || (sub->module->options & VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS))) { + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, sub->module, VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, dbid); /* mark the handler as active to avoid reentrant loops. @@ -8860,12 +8861,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(ValkeyModule *module) { listIter li; listNode *ln; listRewind(moduleKeyspaceSubscribers,&li); while((ln = listNext(&li))) { - RedisModuleKeyspaceSubscriber *sub = ln->value; + ValkeyModuleKeyspaceSubscriber *sub = ln->value; if (sub->module == module) { listDelNode(moduleKeyspaceSubscribers, ln); zfree(sub); @@ -8878,15 +8879,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 (*ValkeyModuleClusterMessageReceiver)(ValkeyModuleCtx *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; + ValkeyModuleClusterMessageReceiver callback; + struct ValkeyModule *module; struct moduleClusterReceiver *next; } moduleClusterReceiver; @@ -8894,7 +8895,7 @@ typedef struct moduleClusterNodeInfo { int flags; char ip[NET_IP_STR_LEN]; int port; - char master_id[40]; /* Only if flags & REDISMODULE_NODE_MASTER is true. */ + char master_id[40]; /* Only if flags & VALKEYMODULE_NODE_PRIMARY is true. */ } mdouleClusterNodeInfo; /* We have an array of message types: each bucket is a linked list of @@ -8906,8 +8907,8 @@ 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; - moduleCreateContext(&ctx, r->module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, r->module, VALKEYMODULE_CTX_TEMP_CLIENT); r->callback(&ctx,sender_id,type,payload,len); moduleFreeContext(&ctx); return; @@ -8921,7 +8922,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 VM_RegisterClusterMessageReceiver(ValkeyModuleCtx *ctx, uint8_t type, ValkeyModuleClusterMessageReceiver callback) { if (!server.cluster_enabled) return; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); @@ -8959,60 +8960,60 @@ void RM_RegisterClusterMessageReceiver(RedisModuleCtx *ctx, uint8_t type, RedisM } /* Send a message to all the nodes in the cluster if `target` is NULL, otherwise - * at the specified target, which is a REDISMODULE_NODE_ID_LEN bytes node ID, as + * at the specified target, which is a VALKEYMODULE_NODE_ID_LEN bytes node ID, as * returned by the receiver callback or by the nodes iteration functions. * - * The function returns REDISMODULE_OK if the message was successfully sent, + * The function returns VALKEYMODULE_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) { - if (!server.cluster_enabled) return REDISMODULE_ERR; + * known cluster node, VALKEYMODULE_ERR is returned. */ +int VM_SendClusterMessage(ValkeyModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) { + if (!server.cluster_enabled) return VALKEYMODULE_ERR; uint64_t module_id = moduleTypeEncodeId(ctx->module->name,0); if (clusterSendModuleMessageToTarget(target_id,module_id,type,msg,len) == C_OK) - return REDISMODULE_OK; + return VALKEYMODULE_OK; else - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Return an array of string pointers, each string pointer points to a cluster - * node ID of exactly REDISMODULE_NODE_ID_LEN bytes (without any null term). + * node ID of exactly VALKEYMODULE_NODE_ID_LEN bytes (without any null term). * The number of returned node IDs is stored into `*numnodes`. * 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 ValkeyModule_GetClusterNodeInfo() in order * to get more information about single node. * * The array returned by this function must be freed using the function - * RedisModule_FreeClusterNodesList(). + * ValkeyModule_FreeClusterNodesList(). * * Example: * * size_t count, j; - * char **ids = RedisModule_GetClusterNodesList(ctx,&count); + * char **ids = ValkeyModule_GetClusterNodesList(ctx,&count); * for (j = 0; j < count; j++) { - * RedisModule_Log(ctx,"notice","Node %.*s", - * REDISMODULE_NODE_ID_LEN,ids[j]); + * ValkeyModule_Log(ctx,"notice","Node %.*s", + * VALKEYMODULE_NODE_ID_LEN,ids[j]); * } - * RedisModule_FreeClusterNodesList(ids); + * ValkeyModule_FreeClusterNodesList(ids); */ -char **RM_GetClusterNodesList(RedisModuleCtx *ctx, size_t *numnodes) { +char **VM_GetClusterNodesList(ValkeyModuleCtx *ctx, size_t *numnodes) { UNUSED(ctx); if (!server.cluster_enabled) return NULL; return getClusterNodesList(numnodes); } -/* Free the node list obtained with RedisModule_GetClusterNodesList. */ -void RM_FreeClusterNodesList(char **ids) { +/* Free the node list obtained with ValkeyModule_GetClusterNodesList. */ +void VM_FreeClusterNodesList(char **ids) { if (ids == NULL) return; for (int j = 0; ids[j]; j++) zfree(ids[j]); zfree(ids); } -/* Return this node ID (REDISMODULE_CLUSTER_ID_LEN bytes) or NULL if the cluster +/* Return this node ID (VALKEYMODULE_CLUSTER_ID_LEN bytes) or NULL if the cluster * is disabled. */ -const char *RM_GetMyClusterID(void) { +const char *VM_GetMyClusterID(void) { if (!server.cluster_enabled) return NULL; return getMyClusterId(); } @@ -9021,38 +9022,38 @@ const char *RM_GetMyClusterID(void) { * (handshake, noaddress, ...) so that the number of active nodes may actually * be smaller, but not greater than this number. If the instance is not in * cluster mode, zero is returned. */ -size_t RM_GetClusterSize(void) { +size_t VM_GetClusterSize(void) { if (!server.cluster_enabled) return 0; return getClusterSize(); } /* Populate the specified info for the node having as ID the specified 'id', - * then returns REDISMODULE_OK. Otherwise if the format of node ID is invalid - * or the node ID does not exist from the POV of this local node, REDISMODULE_ERR + * then returns VALKEYMODULE_OK. Otherwise if the format of node ID is invalid + * or the node ID does not exist from the POV of this local node, VALKEYMODULE_ERR * is returned. * * The arguments `ip`, `master_id`, `port` and `flags` can be NULL in case we don't * need to populate back certain info. If an `ip` and `master_id` (only populated * if the instance is a slave) are specified, they point to buffers holding - * at least REDISMODULE_NODE_ID_LEN bytes. The strings written back as `ip` + * at least VALKEYMODULE_NODE_ID_LEN bytes. The strings written back as `ip` * and `master_id` are not null terminated. * * The list of flags reported is the following: * - * * REDISMODULE_NODE_MYSELF: This node - * * REDISMODULE_NODE_MASTER: The node is a master - * * REDISMODULE_NODE_SLAVE: The node is a replica - * * REDISMODULE_NODE_PFAIL: We see the node as failing - * * REDISMODULE_NODE_FAIL: The cluster agrees the node is failing - * * REDISMODULE_NODE_NOFAILOVER: The slave is configured to never failover + * * VALKEYMODULE_NODE_MYSELF: This node + * * VALKEYMODULE_NODE_PRIMARY: The node is a primary + * * VALKEYMODULE_NODE_REPLICA: The node is a replica + * * VALKEYMODULE_NODE_PFAIL: We see the node as failing + * * VALKEYMODULE_NODE_FAIL: The cluster agrees the node is failing + * * VALKEYMODULE_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 VM_GetClusterNodeInfo(ValkeyModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) { UNUSED(ctx); clusterNode *node = clusterLookupNode(id, strlen(id)); if (node == NULL || clusterNodePending(node)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ip) redis_strlcpy(ip, clusterNodeIp(node),NET_IP_STR_LEN); @@ -9062,9 +9063,9 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * field to zero bytes, so that when the field can't be populated the * function kinda remains predictable. */ if (clusterNodeIsSlave(node) && clusterNodeGetSlaveof(node)) - memcpy(master_id, clusterNodeGetName(clusterNodeGetSlaveof(node)) ,REDISMODULE_NODE_ID_LEN); + memcpy(master_id, clusterNodeGetName(clusterNodeGetSlaveof(node)) ,VALKEYMODULE_NODE_ID_LEN); else - memset(master_id,0,REDISMODULE_NODE_ID_LEN); + memset(master_id,0,VALKEYMODULE_NODE_ID_LEN); } if (port) *port = getNodeDefaultClientPort(node); @@ -9072,14 +9073,14 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m * we can provide binary compatibility. */ if (flags) { *flags = 0; - if (clusterNodeIsMyself(node)) *flags |= REDISMODULE_NODE_MYSELF; - if (clusterNodeIsMaster(node)) *flags |= REDISMODULE_NODE_MASTER; - if (clusterNodeIsSlave(node)) *flags |= REDISMODULE_NODE_SLAVE; - if (clusterNodeTimedOut(node)) *flags |= REDISMODULE_NODE_PFAIL; - if (clusterNodeIsFailing(node)) *flags |= REDISMODULE_NODE_FAIL; - if (clusterNodeIsNoFailover(node)) *flags |= REDISMODULE_NODE_NOFAILOVER; + if (clusterNodeIsMyself(node)) *flags |= VALKEYMODULE_NODE_MYSELF; + if (clusterNodeIsMaster(node)) *flags |= VALKEYMODULE_NODE_PRIMARY; + if (clusterNodeIsSlave(node)) *flags |= VALKEYMODULE_NODE_REPLICA; + if (clusterNodeTimedOut(node)) *flags |= VALKEYMODULE_NODE_PFAIL; + if (clusterNodeIsFailing(node)) *flags |= VALKEYMODULE_NODE_FAIL; + if (clusterNodeIsNoFailover(node)) *flags |= VALKEYMODULE_NODE_NOFAILOVER; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set Redis Cluster flags in order to change the normal behavior of @@ -9100,24 +9101,24 @@ 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 VM_SetClusterFlags(ValkeyModuleCtx *ctx, uint64_t flags) { UNUSED(ctx); - if (flags & REDISMODULE_CLUSTER_FLAG_NO_FAILOVER) + if (flags & VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER) server.cluster_module_flags |= CLUSTER_MODULE_FLAG_NO_FAILOVER; - if (flags & REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION) + if (flags & VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION) server.cluster_module_flags |= CLUSTER_MODULE_FLAG_NO_REDIRECTION; } /* 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 VM_ClusterKeySlot(ValkeyModuleString *key) { return keyHashSlot(key->ptr, sdslen(key->ptr)); } /* Returns a short string that can be used as a key or as a hash tag in a key, * such that the key maps to the given cluster slot. Returns NULL if slot is not * a valid slot. */ -const char *RM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { +const char *VM_ClusterCanonicalKeyNameInSlot(unsigned int slot) { return (slot < CLUSTER_SLOTS) ? crc16_slot_table[slot] : NULL; } @@ -9143,15 +9144,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 (*ValkeyModuleTimerProc)(ValkeyModuleCtx *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 ValkeyModuleTimer { + ValkeyModule *module; /* Module reference. */ + ValkeyModuleTimerProc callback; /* The callback to invoke on expire. */ void *data; /* Private data for the callback. */ int dbid; /* Database number selected by the original client. */ -} RedisModuleTimer; +} ValkeyModuleTimer; /* 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. */ @@ -9172,9 +9173,9 @@ 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; - moduleCreateContext(&ctx,timer->module,REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleTimer *timer = ri.data; + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx,timer->module,VALKEYMODULE_CTX_TEMP_CLIENT); selectDb(ctx.client, timer->dbid); timer->callback(&ctx,timer->data); moduleFreeContext(&ctx); @@ -9207,7 +9208,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 ValkeyModuleTimerProc 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'. @@ -9215,8 +9216,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)); +ValkeyModuleTimerID VM_CreateTimer(ValkeyModuleCtx *ctx, mstime_t period, ValkeyModuleTimerProc callback, void *data) { + ValkeyModuleTimer *timer = zmalloc(sizeof(*timer)); timer->module = ctx->module; timer->callback = callback; timer->data = data; @@ -9260,54 +9261,54 @@ RedisModuleTimerID RM_CreateTimer(RedisModuleCtx *ctx, mstime_t period, RedisMod return key; } -/* Stop a timer, returns REDISMODULE_OK if the timer was found, belonged to the - * calling module, and was stopped, otherwise REDISMODULE_ERR is returned. +/* Stop a timer, returns VALKEYMODULE_OK if the timer was found, belonged to the + * calling module, and was stopped, otherwise VALKEYMODULE_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 VM_StopTimer(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) - return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + return VALKEYMODULE_ERR; + ValkeyModuleTimer *timer = result; if (timer->module != ctx->module) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (data) *data = timer->data; raxRemove(Timers,(unsigned char*)&id,sizeof(id),NULL); zfree(timer); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Obtain information about a timer: its remaining time before firing * (in milliseconds), and the private data pointer associated with the timer. * If the timer specified does not exist or belongs to a different module - * no information is returned and the function returns REDISMODULE_ERR, otherwise - * REDISMODULE_OK is returned. The arguments remaining or data can be NULL if + * no information is returned and the function returns VALKEYMODULE_ERR, otherwise + * VALKEYMODULE_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 VM_GetTimerInfo(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, uint64_t *remaining, void **data) { void *result; if (!raxFind(Timers,(unsigned char*)&id,sizeof(id),&result)) - return REDISMODULE_ERR; - RedisModuleTimer *timer = result; + return VALKEYMODULE_ERR; + ValkeyModuleTimer *timer = result; if (timer->module != ctx->module) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (remaining) { int64_t rem = ntohu64(id)-ustime(); if (rem < 0) rem = 0; *remaining = rem/1000; /* Scale to milliseconds. */ } if (data) *data = timer->data; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 ValkeyModule *module) { raxIterator iter; int found = 0; raxStart(&iter,Timers); raxSeek(&iter,"^",NULL,0); while (raxNext(&iter)) { - RedisModuleTimer *timer = iter.data; + ValkeyModuleTimer *timer = iter.data; if (timer->module == module) { found = 1; break; @@ -9322,13 +9323,13 @@ int moduleHoldsTimer(struct RedisModule *module) { * --------------------------------------------------------------------------*/ typedef struct EventLoopData { - RedisModuleEventLoopFunc rFunc; - RedisModuleEventLoopFunc wFunc; + ValkeyModuleEventLoopFunc rFunc; + ValkeyModuleEventLoopFunc wFunc; void *user_data; } EventLoopData; typedef struct EventLoopOneShot { - RedisModuleEventLoopOneShotFunc func; + ValkeyModuleEventLoopOneShotFunc func; void *user_data; } EventLoopOneShot; @@ -9337,9 +9338,9 @@ static pthread_mutex_t moduleEventLoopMutex = PTHREAD_MUTEX_INITIALIZER; static int eventLoopToAeMask(int mask) { int aeMask = 0; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) aeMask |= AE_READABLE; - if (mask & REDISMODULE_EVENTLOOP_WRITABLE) + if (mask & VALKEYMODULE_EVENTLOOP_WRITABLE) aeMask |= AE_WRITABLE; return aeMask; } @@ -9347,9 +9348,9 @@ static int eventLoopToAeMask(int mask) { static int eventLoopFromAeMask(int ae_mask) { int mask = 0; if (ae_mask & AE_READABLE) - mask |= REDISMODULE_EVENTLOOP_READABLE; + mask |= VALKEYMODULE_EVENTLOOP_READABLE; if (ae_mask & AE_WRITABLE) - mask |= REDISMODULE_EVENTLOOP_WRITABLE; + mask |= VALKEYMODULE_EVENTLOOP_WRITABLE; return mask; } @@ -9369,12 +9370,12 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * * * `mask` must be one of the following values: * - * * `REDISMODULE_EVENTLOOP_READABLE` - * * `REDISMODULE_EVENTLOOP_WRITABLE` - * * `REDISMODULE_EVENTLOOP_READABLE | REDISMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE` + * * `VALKEYMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE | VALKEYMODULE_EVENTLOOP_WRITABLE` * - * On success REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. * * EINVAL: `callback` is NULL or `mask` value is invalid. @@ -9388,23 +9389,23 @@ static void eventLoopCbWritable(struct aeEventLoop *ae, int fd, void *user_data, * int bytes = read(fd,buf,sizeof(buf)); * printf("Read %d bytes \n", bytes); * } - * RM_EventLoopAdd(fd, REDISMODULE_EVENTLOOP_READABLE, onReadable, NULL); + * VM_EventLoopAdd(fd, VALKEYMODULE_EVENTLOOP_READABLE, onReadable, NULL); */ -int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_data) { +int VM_EventLoopAdd(int fd, int mask, ValkeyModuleEventLoopFunc func, void *user_data) { if (fd < 0 || fd >= aeGetSetSize(server.el)) { errno = ERANGE; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (!func || mask & ~(REDISMODULE_EVENTLOOP_READABLE | - REDISMODULE_EVENTLOOP_WRITABLE)) { + if (!func || mask & ~(VALKEYMODULE_EVENTLOOP_READABLE | + VALKEYMODULE_EVENTLOOP_WRITABLE)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* 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 ValkeyModuleEventLoopCallback, * that will be handled it in our stub callbacks. * - We need to remap 'mask' value to provide binary compatibility. * @@ -9417,7 +9418,7 @@ int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_ data = zcalloc(sizeof(*data)); aeFileProc *aeProc; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) aeProc = eventLoopCbReadable; else aeProc = eventLoopCbWritable; @@ -9427,43 +9428,43 @@ int RM_EventLoopAdd(int fd, int mask, RedisModuleEventLoopFunc func, void *user_ if (aeCreateFileEvent(server.el, fd, aeMask, aeProc, data) != AE_OK) { if (aeGetFileEvents(server.el, fd) == AE_NONE) zfree(data); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } data->user_data = user_data; - if (mask & REDISMODULE_EVENTLOOP_READABLE) + if (mask & VALKEYMODULE_EVENTLOOP_READABLE) data->rFunc = func; - if (mask & REDISMODULE_EVENTLOOP_WRITABLE) + if (mask & VALKEYMODULE_EVENTLOOP_WRITABLE) data->wFunc = func; errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Delete a pipe / socket event from the event loop. * * * `mask` must be one of the following values: * - * * `REDISMODULE_EVENTLOOP_READABLE` - * * `REDISMODULE_EVENTLOOP_WRITABLE` - * * `REDISMODULE_EVENTLOOP_READABLE | REDISMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE` + * * `VALKEYMODULE_EVENTLOOP_WRITABLE` + * * `VALKEYMODULE_EVENTLOOP_READABLE | VALKEYMODULE_EVENTLOOP_WRITABLE` * - * On success REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * ERANGE: `fd` is negative or higher than `maxclients` Redis config. * * EINVAL: `mask` value is invalid. */ -int RM_EventLoopDel(int fd, int mask) { +int VM_EventLoopDel(int fd, int mask) { if (fd < 0 || fd >= aeGetSetSize(server.el)) { errno = ERANGE; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (mask & ~(REDISMODULE_EVENTLOOP_READABLE | - REDISMODULE_EVENTLOOP_WRITABLE)) { + if (mask & ~(VALKEYMODULE_EVENTLOOP_READABLE | + VALKEYMODULE_EVENTLOOP_WRITABLE)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* After deleting the event, if fd does not have any registered event @@ -9474,17 +9475,17 @@ int RM_EventLoopDel(int fd, int mask) { zfree(data); errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function can be called from other threads to trigger callback on Redis - * main thread. On success REDISMODULE_OK is returned. If `func` is NULL - * REDISMODULE_ERR is returned and errno is set to EINVAL. + * main thread. On success VALKEYMODULE_OK is returned. If `func` is NULL + * VALKEYMODULE_ERR is returned and errno is set to EINVAL. */ -int RM_EventLoopAddOneShot(RedisModuleEventLoopOneShotFunc func, void *user_data) { +int VM_EventLoopAddOneShot(ValkeyModuleEventLoopOneShotFunc func, void *user_data) { if (!func) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } EventLoopOneShot *oneshot = zmalloc(sizeof(*oneshot)); @@ -9501,7 +9502,7 @@ int RM_EventLoopAddOneShot(RedisModuleEventLoopOneShotFunc func, void *user_data } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This function will check the moduleEventLoopOneShots queue in order to @@ -9572,7 +9573,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(ValkeyModule *module) { listIter li; listNode *ln; listRewind(server.clients,&li); @@ -9580,7 +9581,7 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { client *c = listNodeValue(ln); if (!c->auth_module) continue; - RedisModule *auth_module = (RedisModule *) c->auth_module; + ValkeyModule *auth_module = (ValkeyModule *) c->auth_module; if (auth_module == module) { revokeClientAuthentication(c); } @@ -9589,9 +9590,9 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { /* Creates a Redis ACL user that the module can use to authenticate a client. * After obtaining the user, the module should set what such user can do - * using the RM_SetUserACL() function. Once configured, the user + * using the VM_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 ValkeyModule_AuthClientWithUser() function. * * Note that: * @@ -9602,13 +9603,13 @@ static void moduleFreeAuthenticatedClients(RedisModule *module) { * * The created user can be used to authenticate multiple Redis connections. * * The caller can later free the user using the function - * RM_FreeModuleUser(). When this function is called, if there are + * VM_FreeModuleUser(). When this function is called, if there are * still clients authenticated with this user, they are disconnected. * 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)); +ValkeyModuleUser *VM_CreateModuleUser(const char *name) { + ValkeyModuleUser *new_user = zmalloc(sizeof(ValkeyModuleUser)); new_user->user = ACLCreateUnlinkedUser(); new_user->free_user = 1; @@ -9619,33 +9620,33 @@ 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) { + * authenticated with it. See VM_CreateModuleUser for detailed usage.*/ +int VM_FreeModuleUser(ValkeyModuleUser *user) { if (user->free_user) ACLFreeUserAndKillClients(user->user); zfree(user); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Sets the permissions of a user created through the redis module * interface. The syntax is the same as ACL SETUSER, so refer to the - * documentation in acl.c for more information. See RM_CreateModuleUser + * documentation in acl.c for more information. See VM_CreateModuleUser * for detailed usage. * - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on failure + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on failure * and will set an errno describing why the operation failed. */ -int RM_SetModuleUserACL(RedisModuleUser *user, const char* acl) { +int VM_SetModuleUserACL(ValkeyModuleUser *user, const char* acl) { return ACLSetUser(user->user, acl, -1); } /* Sets the permission of a user with a complete ACL string, such as one * would use on the redis ACL SETUSER command line API. This differs from - * RM_SetModuleUserACL, which only takes single ACL operations at a time. + * VM_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 + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_ERR on failure + * if a ValkeyModuleString 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 VM_SetModuleUserACLString(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, const char *acl, ValkeyModuleString **error) { serverAssert(user != NULL); int argc; @@ -9658,55 +9659,55 @@ int RM_SetModuleUserACLString(RedisModuleCtx *ctx, RedisModuleUser *user, const if (err) { if (error) { *error = createObject(OBJ_STRING, err); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, *error); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, *error); } else { sdsfree(err); } - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get the ACL string for a given user - * Returns a RedisModuleString + * Returns a ValkeyModuleString */ -RedisModuleString *RM_GetModuleUserACLString(RedisModuleUser *user) { +ValkeyModuleString *VM_GetModuleUserACLString(ValkeyModuleUser *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. - * See more information in RM_GetModuleUserFromUserName. + * The user name can be used later, in order to get a ValkeyModuleUser. + * See more information in VM_GetModuleUserFromUserName. * - * The returned string must be released with RedisModule_FreeString() or by + * The returned string must be released with ValkeyModule_FreeString() or by * enabling automatic memory management. */ -RedisModuleString *RM_GetCurrentUserName(RedisModuleCtx *ctx) { - return RM_CreateString(ctx,ctx->client->user->name,sdslen(ctx->client->user->name)); +ValkeyModuleString *VM_GetCurrentUserName(ValkeyModuleCtx *ctx) { + return VM_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 ValkeyModuleUser 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. + * When a Module wants to do ACL checks on a general ACL user (not created by VM_CreateModuleUser), + * it can get the ValkeyModuleUser from this API, based on the user name retrieved by VM_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 ValkeyModuleUser 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) { + * The caller should later free the user using the function VM_FreeModuleUser().*/ +ValkeyModuleUser *VM_GetModuleUserFromUserName(ValkeyModuleString *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)); + ValkeyModuleUser *new_user = zmalloc(sizeof(ValkeyModuleUser)); new_user->user = acl_user; new_user->free_user = 0; return new_user; @@ -9714,136 +9715,136 @@ RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) { /* Checks if the command can be executed by the user, according to the ACLs associated with it. * - * On success a REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to the following values: + * On success a VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to the following values: * * * 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 VM_ACLCheckCommandPermissions(ValkeyModuleUser *user, ValkeyModuleString **argv, int argc) { int keyidxptr; struct serverCommand *cmd; /* Find command */ if ((cmd = lookupCommand(argv, argc)) == NULL) { errno = ENOENT; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (ACLCheckAllUserCommandPerm(user->user, cmd, argv, argc, &keyidxptr) != ACL_OK) { errno = EACCES; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 - * the REDISMODULE_CMD_KEY_ACCESS, REDISMODULE_CMD_KEY_UPDATE, REDISMODULE_CMD_KEY_INSERT, - * and REDISMODULE_CMD_KEY_DELETE flags. + * keyspec for logical operations. These flags are documented in ValkeyModule_SetCommandInfo as + * the VALKEYMODULE_CMD_KEY_ACCESS, VALKEYMODULE_CMD_KEY_UPDATE, VALKEYMODULE_CMD_KEY_INSERT, + * and VALKEYMODULE_CMD_KEY_DELETE flags. * * If no flags are supplied, the user is still required to have some access to the key for * this command to return successfully. * - * If the user is able to access the key then REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to one of the following values: + * If the user is able to access the key then VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to one of the following values: * * * 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) { - const int allow_mask = (REDISMODULE_CMD_KEY_ACCESS - | REDISMODULE_CMD_KEY_INSERT - | REDISMODULE_CMD_KEY_DELETE - | REDISMODULE_CMD_KEY_UPDATE); +int VM_ACLCheckKeyPermissions(ValkeyModuleUser *user, ValkeyModuleString *key, int flags) { + const int allow_mask = (VALKEYMODULE_CMD_KEY_ACCESS + | VALKEYMODULE_CMD_KEY_INSERT + | VALKEYMODULE_CMD_KEY_DELETE + | VALKEYMODULE_CMD_KEY_UPDATE); if ((flags & allow_mask) != flags) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } int keyspec_flags = moduleConvertKeySpecsFlags(flags, 0); if (ACLUserCheckKeyPerm(user->user, key->ptr, sdslen(key->ptr), keyspec_flags) != ACL_OK) { errno = EACCES; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Check if the pubsub channel can be accessed by the user based off of the given - * access flags. See RM_ChannelAtPosWithFlags for more information about the + * access flags. See VM_ChannelAtPosWithFlags for more information about the * possible flags that can be passed in. * - * If the user is able to access the pubsub channel then REDISMODULE_OK is returned, otherwise - * REDISMODULE_ERR is returned and errno is set to one of the following values: + * If the user is able to access the pubsub channel then VALKEYMODULE_OK is returned, otherwise + * VALKEYMODULE_ERR is returned and errno is set to one of the following values: * * * 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) { - const int allow_mask = (REDISMODULE_CMD_CHANNEL_PUBLISH - | REDISMODULE_CMD_CHANNEL_SUBSCRIBE - | REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE - | REDISMODULE_CMD_CHANNEL_PATTERN); +int VM_ACLCheckChannelPermissions(ValkeyModuleUser *user, ValkeyModuleString *ch, int flags) { + const int allow_mask = (VALKEYMODULE_CMD_CHANNEL_PUBLISH + | VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE + | VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE + | VALKEYMODULE_CMD_CHANNEL_PATTERN); if ((flags & allow_mask) != flags) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Unsubscribe permissions are currently always allowed. */ - if (flags & REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE){ - return REDISMODULE_OK; + if (flags & VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE){ + return VALKEYMODULE_OK; } - int is_pattern = flags & REDISMODULE_CMD_CHANNEL_PATTERN; + int is_pattern = flags & VALKEYMODULE_CMD_CHANNEL_PATTERN; if (ACLUserCheckChannelPerm(user->user, ch->ptr, is_pattern) != ACL_OK) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Helper function to map a RedisModuleACLLogEntryReason to ACL Log entry reason. */ -int moduleGetACLLogEntryReason(RedisModuleACLLogEntryReason reason) { +/* Helper function to map a ValkeyModuleACLLogEntryReason to ACL Log entry reason. */ +int moduleGetACLLogEntryReason(ValkeyModuleACLLogEntryReason reason) { int acl_reason = 0; switch (reason) { - case REDISMODULE_ACL_LOG_AUTH: acl_reason = ACL_DENIED_AUTH; break; - case REDISMODULE_ACL_LOG_KEY: acl_reason = ACL_DENIED_KEY; break; - case REDISMODULE_ACL_LOG_CHANNEL: acl_reason = ACL_DENIED_CHANNEL; break; - case REDISMODULE_ACL_LOG_CMD: acl_reason = ACL_DENIED_CMD; break; + case VALKEYMODULE_ACL_LOG_AUTH: acl_reason = ACL_DENIED_AUTH; break; + case VALKEYMODULE_ACL_LOG_KEY: acl_reason = ACL_DENIED_KEY; break; + case VALKEYMODULE_ACL_LOG_CHANNEL: acl_reason = ACL_DENIED_CHANNEL; break; + case VALKEYMODULE_ACL_LOG_CMD: acl_reason = ACL_DENIED_CMD; break; default: break; } return acl_reason; } /* Adds a new entry in the ACL log. - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_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 VM_ACLAddLogEntry(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); - if (!acl_reason) return REDISMODULE_ERR; + if (!acl_reason) return VALKEYMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, user->user->name, sdsdup(object->ptr)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Adds a new entry in the ACL log with the `username` RedisModuleString provided. - * Returns REDISMODULE_OK on success and REDISMODULE_ERR on error. +/* Adds a new entry in the ACL log with the `username` ValkeyModuleString provided. + * Returns VALKEYMODULE_OK on success and VALKEYMODULE_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 VM_ACLAddLogEntryByUserName(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) { int acl_reason = moduleGetACLLogEntryReason(reason); - if (!acl_reason) return REDISMODULE_ERR; + if (!acl_reason) return VALKEYMODULE_ERR; addACLLogEntry(ctx->client, acl_reason, ACL_LOG_CTX_MODULE, -1, username->ptr, sdsdup(object->ptr)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Authenticate the client associated with the context with - * the provided user. Returns REDISMODULE_OK on success and - * REDISMODULE_ERR on error. + * the provided user. Returns VALKEYMODULE_OK on success and + * VALKEYMODULE_ERR on error. * * This authentication can be tracked with the optional callback and private * data fields. The callback will be called whenever the user of the client @@ -9855,20 +9856,20 @@ int RM_ACLAddLogEntryByUserName(RedisModuleCtx *ctx, RedisModuleString *username * * If client_id is not NULL, it will be filled with the id of the client * that was authenticated. This can be used with the - * RM_DeauthenticateAndCloseClient() API in order to deauthenticate a + * VM_DeauthenticateAndCloseClient() API in order to deauthenticate a * previously authenticated client if the authentication is no longer valid. * * 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(ValkeyModuleCtx *ctx, user *user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { if (user->flags & USER_FLAG_DISABLED) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Avoid settings which are meaningless and will be lost */ if (!ctx->client || (ctx->client->flags & CLIENT_MODULE)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } moduleNotifyUserChanged(ctx->client); @@ -9890,29 +9891,29 @@ static int authenticateClientWithUser(RedisModuleCtx *ctx, user *user, RedisModu *client_id = ctx->client->id; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Authenticate the current context's user with the provided redis acl user. - * Returns REDISMODULE_ERR if the user is disabled. + * Returns VALKEYMODULE_ERR if the user is disabled. * * 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 VM_AuthenticateClientWithUser(ValkeyModuleCtx *ctx, ValkeyModuleUser *module_user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { return authenticateClientWithUser(ctx, module_user->user, callback, privdata, client_id); } /* Authenticate the current context's user with the provided redis acl user. - * Returns REDISMODULE_ERR if the user is disabled or the user does not exist. + * Returns VALKEYMODULE_ERR if the user is disabled or the user does not exist. * * 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 VM_AuthenticateClientWithACLUser(ValkeyModuleCtx *ctx, const char *name, size_t len, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) { user *acl_user = ACLGetUserByName(name, len); if (!acl_user) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } return authenticateClientWithUser(ctx, acl_user, callback, privdata, client_id); } @@ -9920,23 +9921,23 @@ int RM_AuthenticateClientWithACLUser(RedisModuleCtx *ctx, const char *name, size /* Deauthenticate and close the client. The client resources will not be * immediately freed, but will be cleaned up in a background job. This is * the recommended way to deauthenticate a client since most clients can't - * handle users becoming deauthenticated. Returns REDISMODULE_ERR when the - * client doesn't exist and REDISMODULE_OK when the operation was successful. + * handle users becoming deauthenticated. Returns VALKEYMODULE_ERR when the + * client doesn't exist and VALKEYMODULE_OK when the operation was successful. * - * The client ID is returned from the RM_AuthenticateClientWithUser and - * RM_AuthenticateClientWithACLUser APIs, but can be obtained through + * The client ID is returned from the VM_AuthenticateClientWithUser and + * VM_AuthenticateClientWithACLUser APIs, but can be obtained through * the CLIENT api or through server events. * * 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 VM_DeauthenticateAndCloseClient(ValkeyModuleCtx *ctx, uint64_t client_id) { UNUSED(ctx); client *c = lookupClientByID(client_id); - if (c == NULL) return REDISMODULE_ERR; + if (c == NULL) return VALKEYMODULE_ERR; /* Revoke also marks client to be closed ASAP */ revokeClientAuthentication(c); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Redact the client command argument specified at the given position. Redacted arguments @@ -9946,21 +9947,21 @@ int RM_DeauthenticateAndCloseClient(RedisModuleCtx *ctx, uint64_t client_id) { * * Note that the command name, position 0, can not be redacted. * - * Returns REDISMODULE_OK if the argument was redacted and REDISMODULE_ERR if there + * Returns VALKEYMODULE_OK if the argument was redacted and VALKEYMODULE_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 VM_RedactClientCommandArgument(ValkeyModuleCtx *ctx, int pos) { if (!ctx || !ctx->client || pos <= 0 || ctx->client->argc <= pos) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } redactClientCommandArgument(ctx->client, pos); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 ValkeyModuleString 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: @@ -9969,15 +9970,15 @@ 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) { +ValkeyModuleString *VM_GetClientCertificate(ValkeyModuleCtx *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); - if (ctx != NULL) autoMemoryAdd(ctx, REDISMODULE_AM_STRING, s); + ValkeyModuleString *s = createObject(OBJ_STRING, cert); + if (ctx != NULL) autoMemoryAdd(ctx, VALKEYMODULE_AM_STRING, s); return s; } @@ -10003,51 +10004,51 @@ 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)); +ValkeyModuleDict *VM_CreateDict(ValkeyModuleCtx *ctx) { + struct ValkeyModuleDict *d = zmalloc(sizeof(*d)); d->rax = raxNew(); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_DICT,d); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_DICT,d); return d; } -/* Free a dictionary created with RM_CreateDict(). You need to pass the +/* Free a dictionary created with VM_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) { - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_DICT,d); +void VM_FreeDict(ValkeyModuleCtx *ctx, ValkeyModuleDict *d) { + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_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 VM_DictSize(ValkeyModuleDict *d) { return raxSize(d->rax); } /* Store the specified key into the dictionary, setting its value to the * 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) { + * already exist, VALKEYMODULE_OK is returned. Otherwise if the key already + * exists the function returns VALKEYMODULE_ERR. */ +int VM_DictSetC(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxTryInsert(d->rax,key,keylen,ptr,NULL); - return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == 1) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictSetC() but will replace the key with the new +/* Like ValkeyModule_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 VM_DictReplaceC(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) { int retval = raxInsert(d->rax,key,keylen,ptr,NULL); - return (retval == 1) ? REDISMODULE_OK : REDISMODULE_ERR; + return (retval == 1) ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictSetC() but takes the key as a RedisModuleString. */ -int RM_DictSet(RedisModuleDict *d, RedisModuleString *key, void *ptr) { - return RM_DictSetC(d,key->ptr,sdslen(key->ptr),ptr); +/* Like ValkeyModule_DictSetC() but takes the key as a ValkeyModuleString. */ +int VM_DictSet(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) { + return VM_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) { - return RM_DictReplaceC(d,key->ptr,sdslen(key->ptr),ptr); +/* Like ValkeyModule_DictReplaceC() but takes the key as a ValkeyModuleString. */ +int VM_DictReplace(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) { + return VM_DictReplaceC(d,key->ptr,sdslen(key->ptr),ptr); } /* Return the value stored at the specified key. The function returns NULL @@ -10055,33 +10056,33 @@ 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 *VM_DictGetC(ValkeyModuleDict *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) { - return RM_DictGetC(d,key->ptr,sdslen(key->ptr),nokey); +/* Like ValkeyModule_DictGetC() but takes the key as a ValkeyModuleString. */ +void *VM_DictGet(ValkeyModuleDict *d, ValkeyModuleString *key, int *nokey) { + return VM_DictGetC(d,key->ptr,sdslen(key->ptr),nokey); } -/* Remove the specified key from the dictionary, returning REDISMODULE_OK if - * the key was found and deleted, or REDISMODULE_ERR if instead there was +/* Remove the specified key from the dictionary, returning VALKEYMODULE_OK if + * the key was found and deleted, or VALKEYMODULE_ERR if instead there was * no such key in the dictionary. When the operation is successful, if * '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 ValkeyModule_DictGet() before deleting the key. */ +int VM_DictDelC(ValkeyModuleDict *d, void *key, size_t keylen, void *oldval) { int retval = raxRemove(d->rax,key,keylen,oldval); - return retval ? REDISMODULE_OK : REDISMODULE_ERR; + return retval ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } -/* Like RedisModule_DictDelC() but gets the key as a RedisModuleString. */ -int RM_DictDel(RedisModuleDict *d, RedisModuleString *key, void *oldval) { - return RM_DictDelC(d,key->ptr,sdslen(key->ptr),oldval); +/* Like ValkeyModule_DictDelC() but gets the key as a ValkeyModuleString. */ +int VM_DictDel(ValkeyModuleDict *d, ValkeyModuleString *key, void *oldval) { + return VM_DictDelC(d,key->ptr,sdslen(key->ptr),oldval); } /* Return an iterator, setup in order to start iterating from the specified @@ -10101,45 +10102,45 @@ 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 - * REDISMODULE_ERR at the first call, otherwise they'll produce elements. + * key and operator passed, ValkeyModule_DictNext() / Prev() will just return + * VALKEYMODULE_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)); +ValkeyModuleDictIter *VM_DictIteratorStartC(ValkeyModuleDict *d, const char *op, void *key, size_t keylen) { + ValkeyModuleDictIter *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) { - return RM_DictIteratorStartC(d,op,key->ptr,sdslen(key->ptr)); +/* Exactly like ValkeyModule_DictIteratorStartC, but the key is passed as a + * ValkeyModuleString. */ +ValkeyModuleDictIter *VM_DictIteratorStart(ValkeyModuleDict *d, const char *op, ValkeyModuleString *key) { + return VM_DictIteratorStartC(d,op,key->ptr,sdslen(key->ptr)); } -/* Release the iterator created with RedisModule_DictIteratorStart(). This call +/* Release the iterator created with ValkeyModule_DictIteratorStart(). This call * is mandatory otherwise a memory leak is introduced in the module. */ -void RM_DictIteratorStop(RedisModuleDictIter *di) { +void VM_DictIteratorStop(ValkeyModuleDictIter *di) { raxStop(&di->ri); zfree(di); } -/* After its creation with RedisModule_DictIteratorStart(), it is possible to +/* After its creation with ValkeyModule_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 - * 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 + * the function ValkeyModule_DictIteratorStart(), however in this case the + * return value is just VALKEYMODULE_OK in case the seeked element was found, + * or VALKEYMODULE_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 VM_DictIteratorReseekC(ValkeyModuleDictIter *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) { - return RM_DictIteratorReseekC(di,op,key->ptr,sdslen(key->ptr)); +/* Like ValkeyModule_DictIteratorReseekC() but takes the key as a + * ValkeyModuleString. */ +int VM_DictIteratorReseek(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) { + return VM_DictIteratorReseekC(di,op,key->ptr,sdslen(key->ptr)); } /* Return the current item of the dictionary iterator `di` and steps to the @@ -10148,14 +10149,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 ValkeyModule_DictSet API). * * Usage example: * * ... create the iterator here ... * char *key; * void *data; - * while((key = RedisModule_DictNextC(iter,&keylen,&data)) != NULL) { + * while((key = ValkeyModule_DictNextC(iter,&keylen,&data)) != NULL) { * printf("%.*s %p\n", (int)keylen, key, data); * } * @@ -10167,71 +10168,71 @@ 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 *VM_DictNextC(ValkeyModuleDictIter *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 ValkeyModule_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 *VM_DictPrevC(ValkeyModuleDictIter *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 ValkeyModuleNextC(), 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 ValkeyModule_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) { +ValkeyModuleString *VM_DictNext(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) { size_t keylen; - void *key = RM_DictNextC(di,&keylen,dataptr); + void *key = VM_DictNextC(di,&keylen,dataptr); if (key == NULL) return NULL; - return RM_CreateString(ctx,key,keylen); + return VM_CreateString(ctx,key,keylen); } -/* Like RedisModule_DictNext() but after returning the currently selected +/* Like ValkeyModule_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) { +ValkeyModuleString *VM_DictPrev(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) { size_t keylen; - void *key = RM_DictPrevC(di,&keylen,dataptr); + void *key = VM_DictPrevC(di,&keylen,dataptr); if (key == NULL) return NULL; - return RM_CreateString(ctx,key,keylen); + return VM_CreateString(ctx,key,keylen); } /* 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). - * If the comparison is successful the command returns REDISMODULE_OK - * otherwise REDISMODULE_ERR is returned. + * valid operators are the same valid for ValkeyModule_DictIteratorStart). + * If the comparison is successful the command returns VALKEYMODULE_OK + * otherwise VALKEYMODULE_ERR is returned. * * This is useful when we want to just emit a lexicographical range, so * in the loop, as we iterate elements, we can also check if we are still * on range. * - * The function return REDISMODULE_ERR if the iterator reached the + * The function return VALKEYMODULE_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) { - if (raxEOF(&di->ri)) return REDISMODULE_ERR; +int VM_DictCompareC(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) { + if (raxEOF(&di->ri)) return VALKEYMODULE_ERR; int res = raxCompare(&di->ri,op,key,keylen); - return res ? REDISMODULE_OK : REDISMODULE_ERR; + return res ? VALKEYMODULE_OK : VALKEYMODULE_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) { - if (raxEOF(&di->ri)) return REDISMODULE_ERR; +/* Like ValkeyModule_DictCompareC but gets the key to compare with the current + * iterator key as a ValkeyModuleString. */ +int VM_DictCompare(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) { + if (raxEOF(&di->ri)) return VALKEYMODULE_ERR; int res = raxCompare(&di->ri,op,key->ptr,sdslen(key->ptr)); - return res ? REDISMODULE_OK : REDISMODULE_ERR; + return res ? VALKEYMODULE_OK : VALKEYMODULE_ERR; } @@ -10241,20 +10242,20 @@ int RM_DictCompare(RedisModuleDictIter *di, const char *op, RedisModuleString *k * ## Modules Info fields * -------------------------------------------------------------------------- */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx); +int VM_InfoEndDictField(ValkeyModuleInfoCtx *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) { + * When return value is VALKEYMODULE_ERR, the section should and will be skipped. */ +int VM_InfoAddSection(ValkeyModuleInfoCtx *ctx, const char *name) { sds full_name = sdsdup(ctx->module->name); if (name != NULL && strlen(name) > 0) full_name = sdscatfmt(full_name, "_%s", name); /* Implicitly end dicts, instead of returning an error which is likely un checked. */ if (ctx->in_dict_field) - RM_InfoEndDictField(ctx); + VM_InfoEndDictField(ctx); /* proceed only if: * 1) no section was requested (emit all) @@ -10266,25 +10267,25 @@ int RM_InfoAddSection(RedisModuleInfoCtx *ctx, const char *name) { { sdsfree(full_name); ctx->in_section = 0; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } if (ctx->sections++) ctx->info = sdscat(ctx->info,"\r\n"); ctx->info = sdscatfmt(ctx->info, "# %S\r\n", full_name); ctx->in_section = 1; sdsfree(full_name); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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) { + * ValkeyModule_InfoAddField* functions to add the items to this field, and + * terminate with ValkeyModule_InfoEndDictField. */ +int VM_InfoBeginDictField(ValkeyModuleInfoCtx *ctx, const char *name) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* Implicitly end dicts, instead of returning an error which is likely un checked. */ if (ctx->in_dict_field) - RM_InfoEndDictField(ctx); + VM_InfoEndDictField(ctx); char *tmpmodname, *tmpname; ctx->info = sdscatfmt(ctx->info, "%s_%s:", @@ -10293,123 +10294,123 @@ int RM_InfoBeginDictField(RedisModuleInfoCtx *ctx, const char *name) { if (tmpmodname != NULL) zfree(tmpmodname); if (tmpname != NULL) zfree(tmpname); ctx->in_dict_field = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Ends a dict field, see RedisModule_InfoBeginDictField */ -int RM_InfoEndDictField(RedisModuleInfoCtx *ctx) { +/* Ends a dict field, see ValkeyModule_InfoBeginDictField */ +int VM_InfoEndDictField(ValkeyModuleInfoCtx *ctx) { if (!ctx->in_dict_field) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; /* trim the last ',' if found. */ if (ctx->info[sdslen(ctx->info)-1]==',') sdsIncrLen(ctx->info, -1); ctx->info = sdscat(ctx->info, "\r\n"); ctx->in_dict_field = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Used by RedisModuleInfoFunc to add info fields. +/* Used by ValkeyModuleInfoFunc 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 VM_InfoAddFieldString(ValkeyModuleInfoCtx *ctx, const char *field, ValkeyModuleString *value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%S,", field, (sds)value->ptr); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%S\r\n", ctx->module->name, field, (sds)value->ptr); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldCString(RedisModuleInfoCtx *ctx, const char *field, const char *value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldCString(ValkeyModuleInfoCtx *ctx, const char *field, const char *value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%s,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%s\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldDouble(RedisModuleInfoCtx *ctx, const char *field, double value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldDouble(ValkeyModuleInfoCtx *ctx, const char *field, double value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatprintf(ctx->info, "%s=%.17g,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatprintf(ctx->info, "%s_%s:%.17g\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldLongLong(RedisModuleInfoCtx *ctx, const char *field, long long value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldLongLong(ValkeyModuleInfoCtx *ctx, const char *field, long long value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%I,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%I\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* See RedisModule_InfoAddFieldString(). */ -int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) { +/* See ValkeyModule_InfoAddFieldString(). */ +int VM_InfoAddFieldULongLong(ValkeyModuleInfoCtx *ctx, const char *field, unsigned long long value) { if (!ctx->in_section) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (ctx->in_dict_field) { ctx->info = sdscatfmt(ctx->info, "%s=%U,", field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } ctx->info = sdscatfmt(ctx->info, "%s_%s:%U\r\n", ctx->module->name, field, value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 `ValkeyModule_InfoAddField*()` functions. */ +int VM_RegisterInfoFunc(ValkeyModuleCtx *ctx, ValkeyModuleInfoFunc cb) { ctx->module->info_cb = cb; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } sds modulesCollectInfo(sds info, dict *sections_dict, int for_crash_report, int sections) { @@ -10417,14 +10418,14 @@ 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 ValkeyModule *module = dictGetVal(de); if (!module->info_cb) continue; - RedisModuleInfoCtx info_ctx = {module, sections_dict, info, sections, 0, 0}; + ValkeyModuleInfoCtx 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) - RM_InfoEndDictField(&info_ctx); + VM_InfoEndDictField(&info_ctx); info = info_ctx.info; sections = info_ctx.sections; } @@ -10435,13 +10436,13 @@ 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 + * ValkeyModule_ServerInfoGetField and alike to get the individual fields. + * When done, it needs to be freed with ValkeyModule_FreeServerInfo or with the * automatic memory management mechanism if enabled. */ -RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *section) { - struct RedisModuleServerInfoData *d = zmalloc(sizeof(*d)); +ValkeyModuleServerInfoData *VM_GetServerInfo(ValkeyModuleCtx *ctx, const char *section) { + struct ValkeyModuleServerInfoData *d = zmalloc(sizeof(*d)); d->rax = raxNew(); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_INFO,d); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_AM_INFO,d); int all = 0, everything = 0; robj *argv[1]; argv[0] = section ? createStringObject(section, strlen(section)) : NULL; @@ -10467,90 +10468,90 @@ RedisModuleServerInfoData *RM_GetServerInfo(RedisModuleCtx *ctx, const char *sec return d; } -/* Free data created with RM_GetServerInfo(). You need to pass the +/* Free data created with VM_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) { - if (ctx != NULL) autoMemoryFreed(ctx,REDISMODULE_AM_INFO,data); +void VM_FreeServerInfo(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data) { + if (ctx != NULL) autoMemoryFreed(ctx,VALKEYMODULE_AM_INFO,data); raxFreeWithCallback(data->rax, (void(*)(void*))sdsfree); zfree(data); } -/* Get the value of a field from data collected with RM_GetServerInfo(). You +/* Get the value of a field from data collected with VM_GetServerInfo(). You * 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) { +ValkeyModuleString *VM_ServerInfoGetField(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *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)); - if (ctx != NULL) autoMemoryAdd(ctx,REDISMODULE_AM_STRING,o); + ValkeyModuleString *o = createStringObject(val,sdslen(val)); + if (ctx != NULL) autoMemoryAdd(ctx,VALKEYMODULE_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) { +/* Similar to VM_ServerInfoGetField, but returns a char* which should not be freed but the caller. */ +const char *VM_ServerInfoGetFieldC(ValkeyModuleServerInfoData *data, const char* field) { void *result = NULL; raxFind(data->rax, (unsigned char *)field, strlen(field), &result); return result; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_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) { + * 0, and the optional out_err argument will be set to VALKEYMODULE_ERR. */ +long long VM_ServerInfoGetFieldSigned(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2ll(val,sdslen(val),&ll)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return ll; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_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) { + * 0, and the optional out_err argument will be set to VALKEYMODULE_ERR. */ +unsigned long long VM_ServerInfoGetFieldUnsigned(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { unsigned long long ll; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2ull(val,&ll)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return ll; } -/* Get the value of a field from data collected with RM_GetServerInfo(). If the +/* Get the value of a field from data collected with VM_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) { + * optional out_err argument will be set to VALKEYMODULE_ERR. */ +double VM_ServerInfoGetFieldDouble(ValkeyModuleServerInfoData *data, const char* field, int *out_err) { double dbl; void *result; if (!raxFind(data->rax, (unsigned char *)field, strlen(field), &result)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } sds val = result; if (!string2d(val,sdslen(val),&dbl)) { - if (out_err) *out_err = REDISMODULE_ERR; + if (out_err) *out_err = VALKEYMODULE_ERR; return 0; } - if (out_err) *out_err = REDISMODULE_OK; + if (out_err) *out_err = VALKEYMODULE_OK; return dbl; } @@ -10562,14 +10563,14 @@ double RM_ServerInfoGetFieldDouble(RedisModuleServerInfoData *data, const char* * initialized seed. This function is fast so can be used to generate * many bytes without any effect on the operating system entropy pool. * Currently this function is not thread safe. */ -void RM_GetRandomBytes(unsigned char *dst, size_t len) { +void VM_GetRandomBytes(unsigned char *dst, size_t len) { getRandomBytes(dst,len); } -/* Like RedisModule_GetRandomBytes() but instead of setting the string to +/* Like ValkeyModule_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) { +void VM_GetRandomHexChars(char *dst, size_t len) { getRandomHexChars(dst,len); } @@ -10579,25 +10580,25 @@ void RM_GetRandomHexChars(char *dst, size_t len) { /* This function is called by a module in order to export some API with a * given name. Other modules will be able to use this API by calling the - * symmetrical function RM_GetSharedAPI() and casting the return value to + * symmetrical function VM_GetSharedAPI() and casting the return value to * the right function pointer. * - * The function will return REDISMODULE_OK if the name is not already taken, - * otherwise REDISMODULE_ERR will be returned and no operation will be + * The function will return VALKEYMODULE_OK if the name is not already taken, + * otherwise VALKEYMODULE_ERR will be returned and no operation will be * performed. * * 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 VM_ExportSharedAPI(ValkeyModuleCtx *ctx, const char *apiname, void *func) { + ValkeyModuleSharedAPI *sapi = zmalloc(sizeof(*sapi)); sapi->module = ctx->module; sapi->func = func; if (dictAdd(server.sharedapi, (char*)apiname, sapi) != DICT_OK) { zfree(sapi); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Request an exported API pointer. The return value is just a void pointer @@ -10627,16 +10628,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 = ValkeyModule_GetSharedAPI("..."); * if (myFunctionPointer == NULL) return 0; * * return 1; * } */ -void *RM_GetSharedAPI(RedisModuleCtx *ctx, const char *apiname) { +void *VM_GetSharedAPI(ValkeyModuleCtx *ctx, const char *apiname) { dictEntry *de = dictFind(server.sharedapi, apiname); if (de == NULL) return NULL; - RedisModuleSharedAPI *sapi = dictGetVal(de); + ValkeyModuleSharedAPI *sapi = dictGetVal(de); if (listSearchKey(sapi->module->usedby,ctx->module) == NULL) { listAddNodeTail(sapi->module->usedby,ctx->module); listAddNodeTail(ctx->module->using,sapi->module); @@ -10650,13 +10651,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(ValkeyModule *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); + ValkeyModuleSharedAPI *sapi = dictGetVal(de); if (sapi->module == module) { dictDelete(server.sharedapi,apiname); zfree(sapi); @@ -10671,14 +10672,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(ValkeyModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->using,&li); while((ln = listNext(&li))) { - RedisModule *used = ln->value; + ValkeyModule *used = ln->value; listNode *ln = listSearchKey(used->usedby,module); if (ln) { listDelNode(used->usedby,ln); @@ -10692,14 +10693,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(ValkeyModule *module) { listIter li; listNode *ln; int count = 0; listRewind(module->filters,&li); while((ln = listNext(&li))) { - RedisModuleCommandFilter *filter = ln->value; + ValkeyModuleCommandFilter *filter = ln->value; listNode *ln = listSearchKey(moduleCommandFilters,filter); if (ln) { listDelNode(moduleCommandFilters,ln); @@ -10724,18 +10725,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 `ValkeyModule_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 ValkeyModuleCtx. 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 + * `ValkeyModule_Call()`, `ValkeyModule_OpenKey()`, etc.) are not supported in a * filter context. * - * The `RedisModuleCommandFilterCtx` can be used to inspect or modify the + * The `ValkeyModuleCommandFilterCtx` 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: @@ -10749,12 +10750,12 @@ 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 - * that is not desired, the `REDISMODULE_CMDFILTER_NOSELF` flag can be set when + * `ValkeyModule_Call()` the filter will be applied on that call as well. If + * that is not desired, the `VALKEYMODULE_CMDFILTER_NOSELF` flag can be set when * registering the filter. * - * The `REDISMODULE_CMDFILTER_NOSELF` flag prevents execution flows that - * originate from the module's own `RM_Call()` from reaching the filter. This + * The `VALKEYMODULE_CMDFILTER_NOSELF` flag prevents execution flows that + * originate from the module's own `VM_Call()` from reaching the filter. This * flag is effective for all execution flows, including nested ones, as long as * the execution begins from the module's command context or a thread-safe * context that is associated with a blocking command. @@ -10765,8 +10766,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)); +ValkeyModuleCommandFilter *VM_RegisterCommandFilter(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilterFunc callback, int flags) { + ValkeyModuleCommandFilter *filter = zmalloc(sizeof(*filter)); filter->module = ctx->module; filter->callback = callback; filter->flags = flags; @@ -10778,23 +10779,23 @@ RedisModuleCommandFilter *RM_RegisterCommandFilter(RedisModuleCtx *ctx, RedisMod /* Unregister a command filter. */ -int RM_UnregisterCommandFilter(RedisModuleCtx *ctx, RedisModuleCommandFilter *filter) { +int VM_UnregisterCommandFilter(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilter *filter) { listNode *ln; /* A module can only remove its own filters */ - if (filter->module != ctx->module) return REDISMODULE_ERR; + if (filter->module != ctx->module) return VALKEYMODULE_ERR; ln = listSearchKey(moduleCommandFilters,filter); - if (!ln) return REDISMODULE_ERR; + if (!ln) return VALKEYMODULE_ERR; listDelNode(moduleCommandFilters,ln); ln = listSearchKey(ctx->module->filters,filter); - if (!ln) return REDISMODULE_ERR; /* Shouldn't happen */ + if (!ln) return VALKEYMODULE_ERR; /* Shouldn't happen */ listDelNode(ctx->module->filters,ln); zfree(filter); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } void moduleCallCommandFilters(client *c) { @@ -10804,7 +10805,7 @@ void moduleCallCommandFilters(client *c) { listNode *ln; listRewind(moduleCommandFilters,&li); - RedisModuleCommandFilterCtx filter = { + ValkeyModuleCommandFilterCtx filter = { .argv = c->argv, .argv_len = c->argv_len, .argc = c->argc, @@ -10812,12 +10813,12 @@ void moduleCallCommandFilters(client *c) { }; while((ln = listNext(&li))) { - RedisModuleCommandFilter *f = ln->value; + ValkeyModuleCommandFilter *f = ln->value; - /* Skip filter if REDISMODULE_CMDFILTER_NOSELF is set and module is + /* Skip filter if VALKEYMODULE_CMDFILTER_NOSELF is set and module is * currently processing a command. */ - if ((f->flags & REDISMODULE_CMDFILTER_NOSELF) && f->module->in_call) continue; + if ((f->flags & VALKEYMODULE_CMDFILTER_NOSELF) && f->module->in_call) continue; /* Call filter */ f->callback(&filter); @@ -10831,7 +10832,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 VM_CommandFilterArgsCount(ValkeyModuleCommandFilterCtx *fctx) { return fctx->argc; } @@ -10839,26 +10840,26 @@ 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) +ValkeyModuleString *VM_CommandFilterArgGet(ValkeyModuleCommandFilterCtx *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 ValkeyModuleString 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 VM_CommandFilterArgInsert(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) { int i; - if (pos < 0 || pos > fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos > fctx->argc) return VALKEYMODULE_ERR; 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(ValkeyModuleString *)); } for (i = fctx->argc; i > pos; i--) { fctx->argv[i] = fctx->argv[i-1]; @@ -10866,31 +10867,31 @@ int RM_CommandFilterArgInsert(RedisModuleCommandFilterCtx *fctx, int pos, RedisM fctx->argv[pos] = arg; fctx->argc++; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 ValkeyModuleString 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 VM_CommandFilterArgReplace(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) { - if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos >= fctx->argc) return VALKEYMODULE_ERR; decrRefCount(fctx->argv[pos]); fctx->argv[pos] = arg; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Modify the filtered command by deleting an argument at the specified * position. */ -int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) +int VM_CommandFilterArgDelete(ValkeyModuleCommandFilterCtx *fctx, int pos) { int i; - if (pos < 0 || pos >= fctx->argc) return REDISMODULE_ERR; + if (pos < 0 || pos >= fctx->argc) return VALKEYMODULE_ERR; decrRefCount(fctx->argv[pos]); for (i = pos; i < fctx->argc-1; i++) { @@ -10898,46 +10899,46 @@ int RM_CommandFilterArgDelete(RedisModuleCommandFilterCtx *fctx, int pos) } fctx->argc--; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Get Client ID for client that issued the command we are filtering */ -unsigned long long RM_CommandFilterGetClientId(RedisModuleCommandFilterCtx *fctx) { +unsigned long long VM_CommandFilterGetClientId(ValkeyModuleCommandFilterCtx *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 ValkeyModule_Alloc() or + * ValkeyModule_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. */ -size_t RM_MallocSize(void* ptr) { +size_t VM_MallocSize(void* ptr) { return zmalloc_size(ptr); } -/* Similar to RM_MallocSize, the difference is that RM_MallocUsableSize +/* Similar to VM_MallocSize, the difference is that VM_MallocUsableSize * returns the usable size of memory by the module. */ -size_t RM_MallocUsableSize(void *ptr) { +size_t VM_MallocUsableSize(void *ptr) { /* It is safe to use 'zmalloc_usable_size()' to manipulate additional * memory space, as we guarantee that the compiler can recognize this - * after 'RM_Alloc', 'RM_TryAlloc', 'RM_Realloc', or 'RM_Calloc'. */ + * after 'VM_Alloc', 'VM_TryAlloc', 'VM_Realloc', or 'VM_Calloc'. */ return zmalloc_usable_size(ptr); } -/* Same as RM_MallocSize, except it works on RedisModuleString pointers. +/* Same as VM_MallocSize, except it works on ValkeyModuleString pointers. */ -size_t RM_MallocSizeString(RedisModuleString* str) { +size_t VM_MallocSizeString(ValkeyModuleString* str) { serverAssert(str->type == OBJ_STRING); return sizeof(*str) + getStringObjectSdsUsedMemory(str); } -/* Same as RM_MallocSize, except it works on RedisModuleDict pointers. +/* Same as VM_MallocSize, except it works on ValkeyModuleDict 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 VM_MallocSizeDict(ValkeyModuleDict* dict) { + size_t size = sizeof(ValkeyModuleDict) + sizeof(rax); size += dict->rax->numnodes * sizeof(raxNode); /* For more info about this weird line, see streamRadixTreeMemoryUsage */ size += dict->rax->numnodes * sizeof(long)*30; @@ -10952,7 +10953,7 @@ size_t RM_MallocSizeDict(RedisModuleDict* dict) { * * Exactly 1 - Memory limit reached. * * Greater 1 - More memory used than the configured limit. */ -float RM_GetUsedMemoryRatio(void){ +float VM_GetUsedMemoryRatio(void){ float level; getMaxmemoryState(NULL, NULL, NULL, &level); return level; @@ -10962,27 +10963,27 @@ float RM_GetUsedMemoryRatio(void){ * ## Scanning keyspace and hashes * -------------------------------------------------------------------------- */ -typedef void (*RedisModuleScanCB)(RedisModuleCtx *ctx, RedisModuleString *keyname, RedisModuleKey *key, void *privdata); +typedef void (*ValkeyModuleScanCB)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, ValkeyModuleKey *key, void *privdata); typedef struct { - RedisModuleCtx *ctx; + ValkeyModuleCtx *ctx; void* user_data; - RedisModuleScanCB fn; + ValkeyModuleScanCB fn; } ScanCBData; -typedef struct RedisModuleScanCursor{ +typedef struct ValkeyModuleScanCursor{ unsigned long long cursor; int done; -}RedisModuleScanCursor; +}ValkeyModuleScanCursor; 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)); + ValkeyModuleString *keyname = createObject(OBJ_STRING,sdsdup(key)); /* Setup the key handle. */ - RedisModuleKey kp = {0}; - moduleInitKey(&kp, data->ctx, keyname, val, REDISMODULE_READ); + ValkeyModuleKey kp = {0}; + moduleInitKey(&kp, data->ctx, keyname, val, VALKEYMODULE_READ); data->fn(data->ctx, keyname, &kp, data->user_data); @@ -10990,22 +10991,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 ValkeyModule_Scan */ +ValkeyModuleScanCursor *VM_ScanCursorCreate(void) { + ValkeyModuleScanCursor* 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 VM_ScanCursorRestart(ValkeyModuleScanCursor *cursor) { cursor->cursor = 0; cursor->done = 0; } /* Destroy the cursor struct. */ -void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { +void VM_ScanCursorDestroy(ValkeyModuleScanCursor *cursor) { zfree(cursor); } @@ -11014,41 +11015,41 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) { * * Callback for scan implementation. * - * void scan_callback(RedisModuleCtx *ctx, RedisModuleString *keyname, - * RedisModuleKey *key, void *privdata); + * void scan_callback(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, + * ValkeyModuleKey *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). + * ValkeyModule_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 ValkeyModule_Scan(). * * The way it should be used: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * while(RedisModule_Scan(ctx, c, callback, privateData)); - * RedisModule_ScanCursorDestroy(c); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * while(ValkeyModule_Scan(ctx, c, callback, privateData)); + * ValkeyModule_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: + * is acquired during the actual call to VM_Scan: * - * RedisModuleScanCursor *c = RedisModule_ScanCursorCreate(); - * RedisModule_ThreadSafeContextLock(ctx); - * while(RedisModule_Scan(ctx, c, callback, privateData)){ - * RedisModule_ThreadSafeContextUnlock(ctx); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModule_ThreadSafeContextLock(ctx); + * while(ValkeyModule_Scan(ctx, c, callback, privateData)){ + * ValkeyModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); + * ValkeyModule_ThreadSafeContextLock(ctx); * } - * RedisModule_ScanCursorDestroy(c); + * ValkeyModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and * 0 otherwise, possibly setting errno if the call failed. * - * It is also possible to restart an existing cursor using RM_ScanCursorRestart. + * It is also possible to restart an existing cursor using VM_ScanCursorRestart. * * IMPORTANT: This API is very similar to the Redis SCAN command from the * point of view of the guarantees it provides. This means that the API @@ -11065,7 +11066,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 VM_Scan(ValkeyModuleCtx *ctx, ValkeyModuleScanCursor *cursor, ValkeyModuleScanCB fn, void *privdata) { if (cursor->done) { errno = ENOENT; return 0; @@ -11081,11 +11082,11 @@ int RM_Scan(RedisModuleCtx *ctx, RedisModuleScanCursor *cursor, RedisModuleScanC return ret; } -typedef void (*RedisModuleScanKeyCB)(RedisModuleKey *key, RedisModuleString *field, RedisModuleString *value, void *privdata); +typedef void (*ValkeyModuleScanKeyCB)(ValkeyModuleKey *key, ValkeyModuleString *field, ValkeyModuleString *value, void *privdata); typedef struct { - RedisModuleKey *key; + ValkeyModuleKey *key; void* user_data; - RedisModuleScanKeyCB fn; + ValkeyModuleScanKeyCB fn; } ScanKeyCBData; static void moduleScanKeyCallback(void *privdata, const dictEntry *de) { @@ -11113,42 +11114,42 @@ 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(ValkeyModuleKey *key, ValkeyModuleString* field, ValkeyModuleString* 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 ValkeyModule_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); + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) + * while(ValkeyModule_ScanKey(key, c, callback, privateData)); + * ValkeyModule_CloseKey(key); + * ValkeyModule_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); + * the actual call to VM_ScanKey, and re-opening the key each time: + * + * ValkeyModuleScanCursor *c = ValkeyModule_ScanCursorCreate(); + * ValkeyModule_ThreadSafeContextLock(ctx); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) + * while(ValkeyModule_ScanKey(ctx, c, callback, privateData)){ + * ValkeyModule_CloseKey(key); + * ValkeyModule_ThreadSafeContextUnlock(ctx); * // do some background job - * RedisModule_ThreadSafeContextLock(ctx); - * RedisModuleKey *key = RedisModule_OpenKey(...) + * ValkeyModule_ThreadSafeContextLock(ctx); + * ValkeyModuleKey *key = ValkeyModule_OpenKey(...) * } - * RedisModule_CloseKey(key); - * RedisModule_ScanCursorDestroy(c); + * ValkeyModule_CloseKey(key); + * ValkeyModule_ScanCursorDestroy(c); * * The function will return 1 if there are more elements to scan and 0 otherwise, * possibly setting errno if the call failed. - * It is also possible to restart an existing cursor using RM_ScanCursorRestart. + * It is also possible to restart an existing cursor using VM_ScanCursorRestart. * * NOTE: Certain operations are unsafe while iterating the object. For instance * while the API guarantees to return at least one time all the elements that @@ -11157,7 +11158,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 VM_ScanKey(ValkeyModuleKey *key, ValkeyModuleScanCursor *cursor, ValkeyModuleScanKeyCB fn, void *privdata) { if (key == NULL || key->value == NULL) { errno = EINVAL; return 0; @@ -11238,14 +11239,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 ValkeyModule_ExitFromChild. + * If the parent wants to kill the child it should call ValkeyModule_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 VM_Fork(ValkeyModuleForkDoneHandler cb, void *user_data) { pid_t childpid; if ((childpid = serverFork(CHILD_TYPE_MODULE)) == 0) { @@ -11266,17 +11267,17 @@ int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { * so that it can report progress and COW memory to the parent which will be * reported in INFO. * The `progress` argument should between 0 and 1, or -1 when not available. */ -void RM_SendChildHeartbeat(double progress) { +void VM_SendChildHeartbeat(double progress) { sendChildInfoGeneric(CHILD_INFO_TYPE_CURRENT_INFO, 0, progress, "Module fork"); } /* Call from the child process when you want to terminate it. * retcode will be provided to the done handler executed on the parent process. */ -int RM_ExitFromChild(int retcode) { +int VM_ExitFromChild(int retcode) { sendChildCowInfo(CHILD_INFO_TYPE_MODULE_COW_SIZE, "Module fork"); exitFromChild(retcode); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Kill the active module forked child, if there is one active and the @@ -11302,13 +11303,13 @@ 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. */ -int RM_KillForkChild(int child_pid) { + * child_pid would be the return value of ValkeyModule_Fork. */ +int VM_KillForkChild(int child_pid) { /* Kill module child, wait for child exit. */ if (TerminateModuleForkChild(child_pid,1) == C_OK) - return REDISMODULE_OK; + return VALKEYMODULE_OK; else - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } void ModuleForkDoneHandler(int exitcode, int bysignal) { @@ -11328,29 +11329,29 @@ void ModuleForkDoneHandler(int exitcode, int bysignal) { * ## Server hooks implementation * -------------------------------------------------------------------------- */ -/* This must be synced with REDISMODULE_EVENT_* +/* This must be synced with VALKEYMODULE_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 ValkeyModule_SubscribeToServerEvent. */ static uint64_t moduleEventVersions[] = { - REDISMODULE_REPLICATIONINFO_VERSION, /* REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED */ - -1, /* REDISMODULE_EVENT_PERSISTENCE */ - REDISMODULE_FLUSHINFO_VERSION, /* REDISMODULE_EVENT_FLUSHDB */ - -1, /* REDISMODULE_EVENT_LOADING */ - REDISMODULE_CLIENTINFO_VERSION, /* REDISMODULE_EVENT_CLIENT_CHANGE */ - -1, /* REDISMODULE_EVENT_SHUTDOWN */ - -1, /* REDISMODULE_EVENT_REPLICA_CHANGE */ - -1, /* REDISMODULE_EVENT_MASTER_LINK_CHANGE */ - REDISMODULE_CRON_LOOP_VERSION, /* REDISMODULE_EVENT_CRON_LOOP */ - REDISMODULE_MODULE_CHANGE_VERSION, /* REDISMODULE_EVENT_MODULE_CHANGE */ - REDISMODULE_LOADING_PROGRESS_VERSION, /* REDISMODULE_EVENT_LOADING_PROGRESS */ - REDISMODULE_SWAPDBINFO_VERSION, /* REDISMODULE_EVENT_SWAPDB */ - -1, /* REDISMODULE_EVENT_REPL_BACKUP */ - -1, /* REDISMODULE_EVENT_FORK_CHILD */ - -1, /* REDISMODULE_EVENT_REPL_ASYNC_LOAD */ - -1, /* REDISMODULE_EVENT_EVENTLOOP */ - -1, /* REDISMODULE_EVENT_CONFIG */ - REDISMODULE_KEYINFO_VERSION, /* REDISMODULE_EVENT_KEY */ + VALKEYMODULE_REPLICATIONINFO_VERSION, /* VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED */ + -1, /* VALKEYMODULE_EVENT_PERSISTENCE */ + VALKEYMODULE_FLUSHINFO_VERSION, /* VALKEYMODULE_EVENT_FLUSHDB */ + -1, /* VALKEYMODULE_EVENT_LOADING */ + VALKEYMODULE_CLIENTINFO_VERSION, /* VALKEYMODULE_EVENT_CLIENT_CHANGE */ + -1, /* VALKEYMODULE_EVENT_SHUTDOWN */ + -1, /* VALKEYMODULE_EVENT_REPLICA_CHANGE */ + -1, /* VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE */ + VALKEYMODULE_CRON_LOOP_VERSION, /* VALKEYMODULE_EVENT_CRON_LOOP */ + VALKEYMODULE_MODULE_CHANGE_VERSION, /* VALKEYMODULE_EVENT_MODULE_CHANGE */ + VALKEYMODULE_LOADING_PROGRESS_VERSION, /* VALKEYMODULE_EVENT_LOADING_PROGRESS */ + VALKEYMODULE_SWAPDBINFO_VERSION, /* VALKEYMODULE_EVENT_SWAPDB */ + -1, /* VALKEYMODULE_EVENT_REPL_BACKUP */ + -1, /* VALKEYMODULE_EVENT_FORK_CHILD */ + -1, /* VALKEYMODULE_EVENT_REPL_ASYNC_LOAD */ + -1, /* VALKEYMODULE_EVENT_EVENTLOOP */ + -1, /* VALKEYMODULE_EVENT_CONFIG */ + VALKEYMODULE_KEYINFO_VERSION, /* VALKEYMODULE_EVENT_KEY */ }; /* Register to be notified, via a callback, when the specified server event @@ -11365,8 +11366,8 @@ static uint64_t moduleEventVersions[] = { * * The callback must be of this type: * - * int (*RedisModuleEventCallback)(RedisModuleCtx *ctx, - * RedisModuleEvent eid, + * int (*ValkeyModuleEventCallback)(ValkeyModuleCtx *ctx, + * ValkeyModuleEvent eid, * uint64_t subevent, * void *data); * @@ -11382,7 +11383,7 @@ static uint64_t moduleEventVersions[] = { * * Here is a list of events you can use as 'eid' and related sub events: * - * * RedisModuleEvent_ReplicationRoleChanged: + * * ValkeyModuleEvent_ReplicationRoleChanged: * * This event is called when the instance switches from master * to replica or the other way around, however the event is @@ -11391,11 +11392,11 @@ static uint64_t moduleEventVersions[] = { * * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_MASTER` - * * `REDISMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA` + * * `VALKEYMODULE_SUBEVENT_REPLROLECHANGED_NOW_PRIMARY` + * * `VALKEYMODULE_SUBEVENT_REPLROLECHANGED_NOW_REPLICA` * * The 'data' field can be casted by the callback to a - * `RedisModuleReplicationInfo` structure with the following fields: + * `ValkeyModuleReplicationInfo` structure with the following fields: * * int master; // true if master, false if replica * char *masterhost; // master instance hostname for NOW_REPLICA @@ -11405,17 +11406,17 @@ static uint64_t moduleEventVersions[] = { * uint64_t repl1_offset; // Main replication offset * uint64_t repl2_offset; // Offset of replid2 validity * - * * RedisModuleEvent_Persistence + * * ValkeyModuleEvent_Persistence * * This event is called when RDB saving or AOF rewriting starts * and ends. The following sub events are available: * - * * `REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_ENDED` - * * `REDISMODULE_SUBEVENT_PERSISTENCE_FAILED` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED` + * * `VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED` * * The above events are triggered not just when the user calls the * relevant commands like BGSAVE, but also when a saving operation @@ -11428,16 +11429,16 @@ 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 + * * ValkeyModuleEvent_FlushDB * * The FLUSHALL, FLUSHDB or an internal flush (for instance * because of replication, after the replica synchronization) * happened. The following sub events are available: * - * * `REDISMODULE_SUBEVENT_FLUSHDB_START` - * * `REDISMODULE_SUBEVENT_FLUSHDB_END` + * * `VALKEYMODULE_SUBEVENT_FLUSHDB_START` + * * `VALKEYMODULE_SUBEVENT_FLUSHDB_END` * - * The data pointer can be casted to a RedisModuleFlushInfo + * The data pointer can be casted to a ValkeyModuleFlushInfo * structure with the following fields: * * int32_t async; // True if the flush is done in a thread. @@ -11452,51 +11453,51 @@ static uint64_t moduleEventVersions[] = { * allowing the callback to call DBSIZE or other operation on the * yet-to-free keyspace. * - * * RedisModuleEvent_Loading + * * ValkeyModuleEvent_Loading * * Called on loading operations: at startup when the server is * started, but also after a first synchronization when the * replica is loading the RDB file from the master. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_LOADING_RDB_START` - * * `REDISMODULE_SUBEVENT_LOADING_AOF_START` - * * `REDISMODULE_SUBEVENT_LOADING_REPL_START` - * * `REDISMODULE_SUBEVENT_LOADING_ENDED` - * * `REDISMODULE_SUBEVENT_LOADING_FAILED` + * * `VALKEYMODULE_SUBEVENT_LOADING_RDB_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_AOF_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_REPL_START` + * * `VALKEYMODULE_SUBEVENT_LOADING_ENDED` + * * `VALKEYMODULE_SUBEVENT_LOADING_FAILED` * * 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 + * * ValkeyModuleEvent_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 ValkeyModuleClientInfo + * structure, documented in ValkeyModule_GetClientInfoById(). * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED` - * * `REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED` + * * `VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED` + * * `VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED` * - * * RedisModuleEvent_Shutdown + * * ValkeyModuleEvent_Shutdown * * The server is shutting down. No subevents are available. * - * * RedisModuleEvent_ReplicaChange + * * ValkeyModuleEvent_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 * replica since it gets disconnected. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE` - * * `REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE` + * * `VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE` + * * `VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE` * * No additional information is available so far: future versions * of Redis will have an API in order to enumerate the replicas * connected and their state. * - * * RedisModuleEvent_CronLoop + * * ValkeyModuleEvent_CronLoop * * This event is called every time Redis calls the serverCron() * function in order to do certain bookkeeping. Modules that are @@ -11505,12 +11506,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 ValkeyModuleCronLoop * structure with the following fields: * * int32_t hz; // Approximate number of events per second. * - * * RedisModuleEvent_MasterLinkChange + * * ValkeyModuleEvent_MasterLinkChange * * This is called for replicas in order to notify when the * replication link becomes functional (up) with our master, @@ -11519,55 +11520,55 @@ static uint64_t moduleEventVersions[] = { * replication is happening correctly. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_MASTER_LINK_UP` - * * `REDISMODULE_SUBEVENT_MASTER_LINK_DOWN` + * * `VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP` + * * `VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN` * - * * RedisModuleEvent_ModuleChange + * * ValkeyModuleEvent_ModuleChange * * This event is called when a new module is loaded or one is unloaded. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_MODULE_LOADED` - * * `REDISMODULE_SUBEVENT_MODULE_UNLOADED` + * * `VALKEYMODULE_SUBEVENT_MODULE_LOADED` + * * `VALKEYMODULE_SUBEVENT_MODULE_UNLOADED` * - * The data pointer can be casted to a RedisModuleModuleChange + * The data pointer can be casted to a ValkeyModuleModuleChange * structure with the following fields: * * const char* module_name; // Name of module loaded or unloaded. * int32_t module_version; // Module version. * - * * RedisModuleEvent_LoadingProgress + * * ValkeyModuleEvent_LoadingProgress * * This event is called repeatedly called while an RDB or AOF file * is being loaded. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB` - * * `REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF` + * * `VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB` + * * `VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF` * - * The data pointer can be casted to a RedisModuleLoadingProgress + * The data pointer can be casted to a ValkeyModuleLoadingProgress * 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 + * * ValkeyModuleEvent_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 ValkeyModuleSwapDbInfo * structure with the following fields: * * int32_t dbnum_first; // Swap Db first dbnum * int32_t dbnum_second; // Swap Db second dbnum * - * * RedisModuleEvent_ReplBackup + * * ValkeyModuleEvent_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 ValkeyModuleEvent_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, @@ -11577,85 +11578,85 @@ static uint64_t moduleEventVersions[] = { * notification to backup / restore / discard its globals. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE` - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE` - * * `REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_CREATE` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_RESTORE` + * * `VALKEYMODULE_SUBEVENT_REPL_BACKUP_DISCARD` * - * * RedisModuleEvent_ReplAsyncLoad + * * ValkeyModuleEvent_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. * In which case redis serves current data set while loading new database in memory from socket. * Modules must have declared they support this mechanism in order to activate it, through - * REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag. + * VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD flag. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED` - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED` - * * `REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED` + * * `VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED` * - * * RedisModuleEvent_ForkChild + * * ValkeyModuleEvent_ForkChild * * Called when a fork child (AOFRW, RDBSAVE, module fork...) is born/dies * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_FORK_CHILD_BORN` - * * `REDISMODULE_SUBEVENT_FORK_CHILD_DIED` + * * `VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN` + * * `VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED` * - * * RedisModuleEvent_EventLoop + * * ValkeyModuleEvent_EventLoop * * Called on each event loop iteration, once just before the event loop goes * to sleep or just after it wakes up. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP` - * * `REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP` + * * `VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP` + * * `VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP` * - * * RedisModule_Event_Config + * * ValkeyModule_Event_Config * * Called when a configuration event happens * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_CONFIG_CHANGE` + * * `VALKEYMODULE_SUBEVENT_CONFIG_CHANGE` * - * The data pointer can be casted to a RedisModuleConfigChange + * The data pointer can be casted to a ValkeyModuleConfigChange * 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 + * * ValkeyModule_Event_Key * * Called when a key is removed from the keyspace. We can't modify any key in * the event. * The following sub events are available: * - * * `REDISMODULE_SUBEVENT_KEY_DELETED` - * * `REDISMODULE_SUBEVENT_KEY_EXPIRED` - * * `REDISMODULE_SUBEVENT_KEY_EVICTED` - * * `REDISMODULE_SUBEVENT_KEY_OVERWRITTEN` + * * `VALKEYMODULE_SUBEVENT_KEY_DELETED` + * * `VALKEYMODULE_SUBEVENT_KEY_EXPIRED` + * * `VALKEYMODULE_SUBEVENT_KEY_EVICTED` + * * `VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN` * - * The data pointer can be casted to a RedisModuleKeyInfo + * The data pointer can be casted to a ValkeyModuleKeyInfo * structure with the following fields: * - * RedisModuleKey *key; // Key name + * ValkeyModuleKey *key; // Key name * - * The function returns REDISMODULE_OK if the module was successfully subscribed + * The function returns VALKEYMODULE_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; + * is given then VALKEYMODULE_ERR is returned. */ +int VM_SubscribeToServerEvent(ValkeyModuleCtx *ctx, ValkeyModuleEvent event, ValkeyModuleEventCallback callback) { + ValkeyModuleEventListener *el; /* Protect in case of calls from contexts without a module reference. */ - if (ctx->module == NULL) return REDISMODULE_ERR; - if (event.id >= _REDISMODULE_EVENT_NEXT) return REDISMODULE_ERR; - if (event.dataver > moduleEventVersions[event.id]) return REDISMODULE_ERR; /* Module compiled with a newer redismodule.h than we support */ + if (ctx->module == NULL) return VALKEYMODULE_ERR; + if (event.id >= _VALKEYMODULE_EVENT_NEXT) return VALKEYMODULE_ERR; + if (event.dataver > moduleEventVersions[event.id]) return VALKEYMODULE_ERR; /* Module compiled with a newer valkeymodule.h than we support */ /* Search an event matching this module and event ID. */ listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == ctx->module && el->event.id == event.id) @@ -11665,12 +11666,12 @@ 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(ValkeyModule_EventListeners,ln); zfree(el); } else { el->callback = callback; /* Update the callback with the new one. */ } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* No event found, we need to add a new one. */ @@ -11678,50 +11679,50 @@ int RM_SubscribeToServerEvent(RedisModuleCtx *ctx, RedisModuleEvent event, Redis el->module = ctx->module; el->event = event; el->callback = callback; - listAddNodeTail(RedisModule_EventListeners,el); - return REDISMODULE_OK; + listAddNodeTail(ValkeyModule_EventListeners,el); + return VALKEYMODULE_OK; } /** * 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 VM_IsSubEventSupported(ValkeyModuleEvent event, int64_t subevent) { switch (event.id) { - case REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED: - return subevent < _REDISMODULE_EVENT_REPLROLECHANGED_NEXT; - case REDISMODULE_EVENT_PERSISTENCE: - return subevent < _REDISMODULE_SUBEVENT_PERSISTENCE_NEXT; - case REDISMODULE_EVENT_FLUSHDB: - return subevent < _REDISMODULE_SUBEVENT_FLUSHDB_NEXT; - case REDISMODULE_EVENT_LOADING: - return subevent < _REDISMODULE_SUBEVENT_LOADING_NEXT; - case REDISMODULE_EVENT_CLIENT_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_CLIENT_CHANGE_NEXT; - case REDISMODULE_EVENT_SHUTDOWN: - return subevent < _REDISMODULE_SUBEVENT_SHUTDOWN_NEXT; - case REDISMODULE_EVENT_REPLICA_CHANGE: - return subevent < _REDISMODULE_EVENT_REPLROLECHANGED_NEXT; - case REDISMODULE_EVENT_MASTER_LINK_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_MASTER_NEXT; - case REDISMODULE_EVENT_CRON_LOOP: - return subevent < _REDISMODULE_SUBEVENT_CRON_LOOP_NEXT; - case REDISMODULE_EVENT_MODULE_CHANGE: - return subevent < _REDISMODULE_SUBEVENT_MODULE_NEXT; - case REDISMODULE_EVENT_LOADING_PROGRESS: - return subevent < _REDISMODULE_SUBEVENT_LOADING_PROGRESS_NEXT; - case REDISMODULE_EVENT_SWAPDB: - return subevent < _REDISMODULE_SUBEVENT_SWAPDB_NEXT; - case REDISMODULE_EVENT_REPL_ASYNC_LOAD: - return subevent < _REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT; - case REDISMODULE_EVENT_FORK_CHILD: - return subevent < _REDISMODULE_SUBEVENT_FORK_CHILD_NEXT; - case REDISMODULE_EVENT_EVENTLOOP: - return subevent < _REDISMODULE_SUBEVENT_EVENTLOOP_NEXT; - case REDISMODULE_EVENT_CONFIG: - return subevent < _REDISMODULE_SUBEVENT_CONFIG_NEXT; - case REDISMODULE_EVENT_KEY: - return subevent < _REDISMODULE_SUBEVENT_KEY_NEXT; + case VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED: + return subevent < _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT; + case VALKEYMODULE_EVENT_PERSISTENCE: + return subevent < _VALKEYMODULE_SUBEVENT_PERSISTENCE_NEXT; + case VALKEYMODULE_EVENT_FLUSHDB: + return subevent < _VALKEYMODULE_SUBEVENT_FLUSHDB_NEXT; + case VALKEYMODULE_EVENT_LOADING: + return subevent < _VALKEYMODULE_SUBEVENT_LOADING_NEXT; + case VALKEYMODULE_EVENT_CLIENT_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_NEXT; + case VALKEYMODULE_EVENT_SHUTDOWN: + return subevent < _VALKEYMODULE_SUBEVENT_SHUTDOWN_NEXT; + case VALKEYMODULE_EVENT_REPLICA_CHANGE: + return subevent < _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT; + case VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_PRIMARY_NEXT; + case VALKEYMODULE_EVENT_CRON_LOOP: + return subevent < _VALKEYMODULE_SUBEVENT_CRON_LOOP_NEXT; + case VALKEYMODULE_EVENT_MODULE_CHANGE: + return subevent < _VALKEYMODULE_SUBEVENT_MODULE_NEXT; + case VALKEYMODULE_EVENT_LOADING_PROGRESS: + return subevent < _VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_NEXT; + case VALKEYMODULE_EVENT_SWAPDB: + return subevent < _VALKEYMODULE_SUBEVENT_SWAPDB_NEXT; + case VALKEYMODULE_EVENT_REPL_ASYNC_LOAD: + return subevent < _VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT; + case VALKEYMODULE_EVENT_FORK_CHILD: + return subevent < _VALKEYMODULE_SUBEVENT_FORK_CHILD_NEXT; + case VALKEYMODULE_EVENT_EVENTLOOP: + return subevent < _VALKEYMODULE_SUBEVENT_EVENTLOOP_NEXT; + case VALKEYMODULE_EVENT_CONFIG: + return subevent < _VALKEYMODULE_SUBEVENT_CONFIG_NEXT; + case VALKEYMODULE_EVENT_KEY: + return subevent < _VALKEYMODULE_SUBEVENT_KEY_NEXT; default: break; } @@ -11730,7 +11731,7 @@ int RM_IsSubEventSupported(RedisModuleEvent event, int64_t subevent) { typedef struct KeyInfo { int32_t dbnum; - RedisModuleString *key; + ValkeyModuleString *key; robj *value; int mode; } KeyInfo; @@ -11746,65 +11747,65 @@ 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(ValkeyModule_EventListeners) == 0) return; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { - RedisModuleEventListener *el = ln->value; + ValkeyModuleEventListener *el = ln->value; if (el->event.id == eid) { - RedisModuleCtx ctx; - if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { + ValkeyModuleCtx ctx; + if (eid == VALKEYMODULE_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, * to change its authentication state in a way that does not * depend on specific commands executed later. */ - moduleCreateContext(&ctx,el->module,REDISMODULE_CTX_NONE); + moduleCreateContext(&ctx,el->module,VALKEYMODULE_CTX_NONE); ctx.client = (client *) data; } else { - moduleCreateContext(&ctx,el->module,REDISMODULE_CTX_TEMP_CLIENT); + moduleCreateContext(&ctx,el->module,VALKEYMODULE_CTX_TEMP_CLIENT); } void *moduledata = NULL; - RedisModuleClientInfoV1 civ1; - RedisModuleReplicationInfoV1 riv1; - RedisModuleModuleChangeV1 mcv1; - RedisModuleKey key; - RedisModuleKeyInfoV1 ki = {REDISMODULE_KEYINFO_VERSION, &key}; + ValkeyModuleClientInfoV1 civ1; + ValkeyModuleReplicationInfoV1 riv1; + ValkeyModuleModuleChangeV1 mcv1; + ValkeyModuleKey key; + ValkeyModuleKeyInfoV1 ki = {VALKEYMODULE_KEYINFO_VERSION, &key}; /* Event specific context and data pointer setup. */ - if (eid == REDISMODULE_EVENT_CLIENT_CHANGE) { - serverAssert(modulePopulateClientInfoStructure(&civ1,data, el->event.dataver) == REDISMODULE_OK); + if (eid == VALKEYMODULE_EVENT_CLIENT_CHANGE) { + serverAssert(modulePopulateClientInfoStructure(&civ1,data, el->event.dataver) == VALKEYMODULE_OK); moduledata = &civ1; - } else if (eid == REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED) { - serverAssert(modulePopulateReplicationInfoStructure(&riv1,el->event.dataver) == REDISMODULE_OK); + } else if (eid == VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED) { + serverAssert(modulePopulateReplicationInfoStructure(&riv1,el->event.dataver) == VALKEYMODULE_OK); moduledata = &riv1; - } else if (eid == REDISMODULE_EVENT_FLUSHDB) { + } else if (eid == VALKEYMODULE_EVENT_FLUSHDB) { moduledata = data; - RedisModuleFlushInfoV1 *fi = data; + ValkeyModuleFlushInfoV1 *fi = data; if (fi->dbnum != -1) selectDb(ctx.client, fi->dbnum); - } else if (eid == REDISMODULE_EVENT_MODULE_CHANGE) { - RedisModule *m = data; + } else if (eid == VALKEYMODULE_EVENT_MODULE_CHANGE) { + ValkeyModule *m = data; if (m == el->module) { moduleFreeContext(&ctx); continue; } - mcv1.version = REDISMODULE_MODULE_CHANGE_VERSION; + mcv1.version = VALKEYMODULE_MODULE_CHANGE_VERSION; mcv1.module_name = m->name; mcv1.module_version = m->ver; moduledata = &mcv1; - } else if (eid == REDISMODULE_EVENT_LOADING_PROGRESS) { + } else if (eid == VALKEYMODULE_EVENT_LOADING_PROGRESS) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_CRON_LOOP) { + } else if (eid == VALKEYMODULE_EVENT_CRON_LOOP) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_SWAPDB) { + } else if (eid == VALKEYMODULE_EVENT_SWAPDB) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_CONFIG) { + } else if (eid == VALKEYMODULE_EVENT_CONFIG) { moduledata = data; - } else if (eid == REDISMODULE_EVENT_KEY) { + } else if (eid == VALKEYMODULE_EVENT_KEY) { KeyInfo *info = data; selectDb(ctx.client, info->dbnum); moduleInitKey(&key, &ctx, info->key, info->value, info->mode); @@ -11815,7 +11816,7 @@ void moduleFireServerEvent(uint64_t eid, int subid, void *data) { el->callback(&ctx,el->event,subid,moduledata); el->module->in_hook--; - if (eid == REDISMODULE_EVENT_KEY) { + if (eid == VALKEYMODULE_EVENT_KEY) { moduleCloseKey(&key); } @@ -11826,16 +11827,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(ValkeyModule *module) { + ValkeyModuleEventListener *el; listIter li; listNode *ln; - listRewind(RedisModule_EventListeners,&li); + listRewind(ValkeyModule_EventListeners,&li); while((ln = listNext(&li))) { el = ln->value; if (el->module == module) { - listDelNode(RedisModule_EventListeners,ln); + listDelNode(ValkeyModule_EventListeners,ln); zfree(el); } } @@ -11849,13 +11850,13 @@ 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, + ValkeyModuleLoadingProgressV1 fi = {VALKEYMODULE_LOADING_PROGRESS_VERSION, server.hz, progress}; - moduleFireServerEvent(REDISMODULE_EVENT_LOADING_PROGRESS, + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING_PROGRESS, is_aof? - REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF: - REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB, + VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF: + VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB, &fi); /* decide when the next event should fire. */ next_event = now + 1000000 / server.hz; @@ -11866,23 +11867,23 @@ void processModuleLoadingProgressEvent(int is_aof) { * will be called to tell the module which key is about to be released. */ void moduleNotifyKeyUnlink(robj *key, robj *val, int dbid, int flags) { server.lazy_expire_disabled++; - int subevent = REDISMODULE_SUBEVENT_KEY_DELETED; + int subevent = VALKEYMODULE_SUBEVENT_KEY_DELETED; if (flags & DB_FLAG_KEY_EXPIRED) { - subevent = REDISMODULE_SUBEVENT_KEY_EXPIRED; + subevent = VALKEYMODULE_SUBEVENT_KEY_EXPIRED; } else if (flags & DB_FLAG_KEY_EVICTED) { - subevent = REDISMODULE_SUBEVENT_KEY_EVICTED; + subevent = VALKEYMODULE_SUBEVENT_KEY_EVICTED; } else if (flags & DB_FLAG_KEY_OVERWRITE) { - subevent = REDISMODULE_SUBEVENT_KEY_OVERWRITTEN; + subevent = VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN; } - KeyInfo info = {dbid, key, val, REDISMODULE_READ}; - moduleFireServerEvent(REDISMODULE_EVENT_KEY, subevent, &info); + KeyInfo info = {dbid, key, val, VALKEYMODULE_READ}; + moduleFireServerEvent(VALKEYMODULE_EVENT_KEY, subevent, &info); if (val->type == OBJ_MODULE) { moduleValue *mv = val->ptr; moduleType *mt = mv->type; /* We prefer to use the enhanced version. */ if (mt->unlink2 != NULL) { - RedisModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; + ValkeyModuleKeyOptCtx ctx = {key, NULL, dbid, -1}; mt->unlink2(&ctx,mv->value); } else if (mt->unlink != NULL) { mt->unlink(key,mv->value); @@ -11900,7 +11901,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}; + ValkeyModuleKeyOptCtx 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); @@ -11917,7 +11918,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}; + ValkeyModuleKeyOptCtx 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); @@ -11956,8 +11957,11 @@ int moduleRegisterApi(const char *funcname, void *funcptr) { return dictAdd(server.moduleapi, (char*)funcname, funcptr); } +/* Register Module APIs under both RedisModule_ and ValkeyModule_ namespaces + * so that legacy Redis module binaries can continue to function */ #define REGISTER_API(name) \ - moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)RM_ ## name) + moduleRegisterApi("ValkeyModule_" #name, (void *)(unsigned long)VM_ ## name);\ + moduleRegisterApi("RedisModule_" #name, (void *)(unsigned long)VM_ ## name);\ /* Global initialization at Redis startup. */ void moduleRegisterCoreAPI(void); @@ -12013,10 +12017,10 @@ void moduleInitModulesSystem(void) { Timers = raxNew(); /* Setup the event listeners data structures. */ - RedisModule_EventListeners = listCreate(); + ValkeyModule_EventListeners = listCreate(); /* Making sure moduleEventVersions is synced with the number of events. */ - serverAssert(sizeof(moduleEventVersions)/sizeof(moduleEventVersions[0]) == _REDISMODULE_EVENT_NEXT); + serverAssert(sizeof(moduleEventVersions)/sizeof(moduleEventVersions[0]) == _VALKEYMODULE_EVENT_NEXT); /* Our thread-safe contexts GIL must start with already locked: * it is just unlocked when it's safe. */ @@ -12061,7 +12065,7 @@ void moduleLoadQueueEntryFree(struct moduleLoadQueueEntry *loadmod) { } /* Remove Module Configs from standardConfig array in config.c */ -void moduleRemoveConfigs(RedisModule *module) { +void moduleRemoveConfigs(ValkeyModule *module) { listIter li; listNode *ln; listRewind(module->module_configs, &li); @@ -12075,7 +12079,7 @@ void moduleRemoveConfigs(RedisModule *module) { } /* Remove ACL categories added by the module when it fails to load. */ -void moduleRemoveCateogires(RedisModule *module) { +void moduleRemoveCateogires(ValkeyModule *module) { if (module->num_acl_categories_added) { ACLCleanupCategoriesOnFailure(module->num_acl_categories_added); } @@ -12121,7 +12125,7 @@ void moduleLoadFromQueue(void) { } } -void moduleFreeModuleStructure(struct RedisModule *module) { +void moduleFreeModuleStructure(struct ValkeyModule *module) { listRelease(module->types); listRelease(module->filters); listRelease(module->usedby); @@ -12154,11 +12158,11 @@ void moduleFreeArgs(struct serverCommandArg *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 serverCommand *cmd) { - if (cmd->proc != RedisModuleCommandDispatcher) +int moduleFreeCommand(struct ValkeyModule *module, struct serverCommand *cmd) { + if (cmd->proc != ValkeyModuleCommandDispatcher) return C_ERR; - RedisModuleCommand *cp = cmd->module_cmd; + ValkeyModuleCommand *cp = cmd->module_cmd; if (cp->module != module) return C_ERR; @@ -12208,7 +12212,7 @@ int moduleFreeCommand(struct RedisModule *module, struct serverCommand *cmd) { return C_OK; } -void moduleUnregisterCommands(struct RedisModule *module) { +void moduleUnregisterCommands(struct ValkeyModule *module) { /* Unregister all the commands registered by this module. */ dictIterator *di = dictGetSafeIterator(server.commands); dictEntry *de; @@ -12228,16 +12232,16 @@ 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(ValkeyModuleString ***module_argv, int *module_argc) { int args_specified = 0; - RedisModuleString **argv = *module_argv; + ValkeyModuleString **argv = *module_argv; int argc = *module_argc; for (int i = 0; i < argc; i++) { char *arg_val = argv[i]->ptr; if (!strcasecmp(arg_val, "CONFIG")) { if (i + 2 >= argc) { serverLog(LL_NOTICE, "CONFIG specified without name value pair"); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } sds name = sdsdup(argv[i + 1]->ptr); sds value = sdsdup(argv[i + 2]->ptr); @@ -12256,18 +12260,18 @@ int parseLoadexArguments(RedisModuleString ***module_argv, int *module_argc) { break; } else { serverLog(LL_NOTICE, "Syntax Error from arguments to loadex around %s.", arg_val); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } if (!args_specified) { *module_argv = NULL; *module_argc = 0; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Unregister module-related things, called when moduleLoad fails or moduleUnload. */ -void moduleUnregisterCleanup(RedisModule *module) { +void moduleUnregisterCleanup(ValkeyModule *module) { moduleFreeAuthenticatedClients(module); moduleUnregisterCommands(module); moduleUnsubscribeNotifications(module); @@ -12299,17 +12303,28 @@ 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"); + + const char *onLoadNames[] = {"ValkeyModule_OnLoad", "RedisModule_OnLoad"}; + for (size_t i = 0; i < sizeof(onLoadNames) / sizeof(onLoadNames[0]); i++) { + onload = (int (*)(void *, void **, int))(unsigned long) dlsym(handle, onLoadNames[i]); + if (onload != NULL) { + if (i != 0) { + serverLog(LL_NOTICE, "Legacy Redis Module %s found", path); + } + break; + } + } + if (onload == NULL) { dlclose(handle); serverLog(LL_WARNING, - "Module %s does not export RedisModule_OnLoad() " + "Module %s does not export ValkeyModule_OnLoad() or RedisModule_OnLoad() " "symbol. Module not loaded.",path); return C_ERR; } - RedisModuleCtx 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) { + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, NULL, VALKEYMODULE_CTX_TEMP_CLIENT); /* We pass NULL since we don't have a module yet. */ + if (onload((void*)&ctx,module_argv,module_argc) == VALKEYMODULE_ERR) { serverLog(LL_WARNING, "Module %s initialization failed. Module not loaded",path); if (ctx.module) { @@ -12361,8 +12376,8 @@ int moduleLoad(const char *path, void **module_argv, int module_argc, int is_loa } /* Fire the loaded modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MODULE_CHANGE, - REDISMODULE_SUBEVENT_MODULE_LOADED, + moduleFireServerEvent(VALKEYMODULE_EVENT_MODULE_CHANGE, + VALKEYMODULE_SUBEVENT_MODULE_LOADED, ctx.module); moduleFreeContext(&ctx); @@ -12373,7 +12388,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 ValkeyModule *module = dictFetchValue(modules,name); if (module == NULL) { *errmsg = "no such module with that name"; @@ -12397,16 +12412,26 @@ 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"); + const char *onUnloadNames[] = {"ValkeyModule_OnUnload", "RedisModule_OnUnload"}; + int (*onunload)(void *) = NULL; + for (size_t i = 0; i < sizeof(onUnloadNames) / sizeof(onUnloadNames[0]); i++) { + onunload = (int (*)(void *))(unsigned long)dlsym(module->handle, onUnloadNames[i]); + if (onunload) { + if (i != 0) { + serverLog(LL_NOTICE, "Legacy Redis Module %s found", name); + } + break; + } + } + if (onunload) { - RedisModuleCtx ctx; - moduleCreateContext(&ctx, module, REDISMODULE_CTX_TEMP_CLIENT); + ValkeyModuleCtx ctx; + moduleCreateContext(&ctx, module, VALKEYMODULE_CTX_TEMP_CLIENT); int unload_status = onunload((void*)&ctx); moduleFreeContext(&ctx); - if (unload_status == REDISMODULE_ERR) { - serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); + if (unload_status == VALKEYMODULE_ERR) { + serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); errno = ECANCELED; return C_ERR; } @@ -12423,8 +12448,8 @@ int moduleUnload(sds name, const char **errmsg) { } /* Fire the unloaded modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MODULE_CHANGE, - REDISMODULE_SUBEVENT_MODULE_UNLOADED, + moduleFireServerEvent(VALKEYMODULE_EVENT_MODULE_CHANGE, + VALKEYMODULE_SUBEVENT_MODULE_UNLOADED, module); /* Remove from list of modules. */ @@ -12460,7 +12485,7 @@ void addReplyLoadedModules(client *c) { addReplyArrayLen(c,dictSize(modules)); while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); sds path = module->loadmod->path; addReplyMapLen(c,4); addReplyBulkCString(c,"name"); @@ -12486,7 +12511,7 @@ sds genModulesInfoStringRenderModulesList(list *l) { listRewind(l,&li); sds output = sdsnew("["); while((ln = listNext(&li))) { - RedisModule *module = ln->value; + ValkeyModule *module = ln->value; output = sdscat(output,module->name); if (ln != listLast(l)) output = sdscat(output,"|"); @@ -12496,13 +12521,13 @@ sds genModulesInfoStringRenderModulesList(list *l) { } /* Helper for genModulesInfoString(): render module options as an SDS string. */ -sds genModulesInfoStringRenderModuleOptions(struct RedisModule *module) { +sds genModulesInfoStringRenderModuleOptions(struct ValkeyModule *module) { sds output = sdsnew("["); - if (module->options & REDISMODULE_OPTIONS_HANDLE_IO_ERRORS) + if (module->options & VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS) output = sdscat(output,"handle-io-errors|"); - if (module->options & REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD) + if (module->options & VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD) output = sdscat(output,"handle-repl-async-load|"); - if (module->options & REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) + if (module->options & VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED) output = sdscat(output,"no-implicit-signal-modified|"); output = sdstrim(output,"|"); output = sdscat(output,"]"); @@ -12514,6 +12539,7 @@ sds genModulesInfoStringRenderModuleOptions(struct RedisModule *module) { * output. * * After the call, the passed sds info string is no longer valid and all the + * * references must be substituted with the new pointer returned by the call. */ sds genModulesInfoString(sds info) { dictIterator *di = dictGetIterator(modules); @@ -12521,7 +12547,7 @@ sds genModulesInfoString(sds info) { while ((de = dictNext(di)) != NULL) { sds name = dictGetKey(de); - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); sds usedby = genModulesInfoStringRenderModulesList(module->usedby); sds using = genModulesInfoStringRenderModulesList(module->using); @@ -12544,40 +12570,40 @@ sds genModulesInfoString(sds info) { * -------------------------------------------------------------------------- */ /* Check if the configuration name is already registered */ -int isModuleConfigNameRegistered(RedisModule *module, const char *name) { +int isModuleConfigNameRegistered(ValkeyModule *module, const char *name) { listNode *match = listSearchKey(module->module_configs, (void *) name); return match != NULL; } -/* Assert that the flags passed into the RM_RegisterConfig Suite are valid */ +/* Assert that the flags passed into the VM_RegisterConfig Suite are valid */ int moduleVerifyConfigFlags(unsigned int flags, configType type) { - if ((flags & ~(REDISMODULE_CONFIG_DEFAULT - | REDISMODULE_CONFIG_IMMUTABLE - | REDISMODULE_CONFIG_SENSITIVE - | REDISMODULE_CONFIG_HIDDEN - | REDISMODULE_CONFIG_PROTECTED - | REDISMODULE_CONFIG_DENY_LOADING - | REDISMODULE_CONFIG_BITFLAGS - | REDISMODULE_CONFIG_MEMORY))) { + if ((flags & ~(VALKEYMODULE_CONFIG_DEFAULT + | VALKEYMODULE_CONFIG_IMMUTABLE + | VALKEYMODULE_CONFIG_SENSITIVE + | VALKEYMODULE_CONFIG_HIDDEN + | VALKEYMODULE_CONFIG_PROTECTED + | VALKEYMODULE_CONFIG_DENY_LOADING + | VALKEYMODULE_CONFIG_BITFLAGS + | VALKEYMODULE_CONFIG_MEMORY))) { serverLogRaw(LL_WARNING, "Invalid flag(s) for configuration"); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (type != NUMERIC_CONFIG && flags & REDISMODULE_CONFIG_MEMORY) { + if (type != NUMERIC_CONFIG && flags & VALKEYMODULE_CONFIG_MEMORY) { serverLogRaw(LL_WARNING, "Numeric flag provided for non-numeric configuration."); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (type != ENUM_CONFIG && flags & REDISMODULE_CONFIG_BITFLAGS) { + if (type != ENUM_CONFIG && flags & VALKEYMODULE_CONFIG_BITFLAGS) { serverLogRaw(LL_WARNING, "Enum flag provided for non-enum configuration."); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Verify a module resource or name has only alphanumeric characters, underscores * or dashes. */ int moduleVerifyResourceName(const char *name) { if (name[0] == '\0') { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } for (size_t i = 0; name[i] != '\0'; i++) { @@ -12590,16 +12616,16 @@ int moduleVerifyResourceName(const char *name) { continue; } serverLog(LL_WARNING, "Invalid character %c in Module resource name %s.", curr_char, name); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a series of set functions for each type that act as dispatchers for * 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(ValkeyModuleString *err_in, const char **err) { if (err_in) { redis_strlcpy(configerr, err_in->ptr, CONFIG_ERR_SIZE); decrRefCount(err_in); @@ -12608,33 +12634,33 @@ static void propagateErrorString(RedisModuleString *err_in, const char **err) { } int setModuleBoolConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *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; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleStringConfig(ModuleConfig *config, sds strval, const char **err) { - RedisModuleString *error = NULL; - RedisModuleString *new = createStringObject(strval, sdslen(strval)); + ValkeyModuleString *error = NULL; + ValkeyModuleString *new = createStringObject(strval, sdslen(strval)); int return_code = config->set_fn.set_string(config->name, new, config->privdata, &error); propagateErrorString(error, err); decrRefCount(new); - return return_code == REDISMODULE_OK ? 1 : 0; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleEnumConfig(ModuleConfig *config, int val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *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; + return return_code == VALKEYMODULE_OK ? 1 : 0; } int setModuleNumericConfig(ModuleConfig *config, long long val, const char **err) { - RedisModuleString *error = NULL; + ValkeyModuleString *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; + return return_code == VALKEYMODULE_OK ? 1 : 0; } /* This is a series of get functions for each type that act as dispatchers for @@ -12644,7 +12670,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); + ValkeyModuleString *val = module_config->get_fn.get_string(module_config->name, module_config->privdata); return val ? sdsdup(val->ptr) : NULL; } @@ -12658,7 +12684,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(ValkeyModule *module) { listIter li; listNode *ln; const char *err = NULL; @@ -12672,21 +12698,21 @@ int loadModuleConfigs(RedisModule *module) { serverLog(LL_WARNING, "Issue during loading of configuration %s : %s", (sds) dictGetKey(config_argument), err); sdsfree(config_name); dictEmpty(server.module_configs_queue, NULL); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } else { if (!performModuleConfigSetDefaultFromName(config_name, &err)) { serverLog(LL_WARNING, "Issue attempting to set default value of configuration %s : %s", module_config->name, err); sdsfree(config_name); dictEmpty(server.module_configs_queue, NULL); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } } dictDelete(server.module_configs_queue, config_name); sdsfree(config_name); } module->configs_initialized = 1; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Add module_config to the list if the apply and privdata do not match one already in it. */ @@ -12711,13 +12737,13 @@ int moduleConfigApplyConfig(list *module_configs, const char **err, const char * listIter li; listNode *ln; ModuleConfig *module_config; - RedisModuleString *error = NULL; - RedisModuleCtx ctx; + ValkeyModuleString *error = NULL; + ValkeyModuleCtx ctx; listRewind(module_configs, &li); while ((ln = listNext(&li))) { module_config = listNodeValue(ln); - moduleCreateContext(&ctx, module_config->module, REDISMODULE_CTX_NONE); + moduleCreateContext(&ctx, module_config->module, VALKEYMODULE_CTX_NONE); if (module_config->apply_fn(&ctx, module_config->privdata, &error)) { if (err_arg_name) *err_arg_name = module_config->name; propagateErrorString(error, err); @@ -12734,7 +12760,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, ValkeyModuleConfigApplyFunc apply_fn, void *privdata, ValkeyModule *module) { ModuleConfig *new_config = zmalloc(sizeof(ModuleConfig)); new_config->name = sdsnew(name); new_config->apply_fn = apply_fn; @@ -12743,42 +12769,42 @@ ModuleConfig *createModuleConfig(const char *name, RedisModuleConfigApplyFunc ap return new_config; } -int moduleConfigValidityCheck(RedisModule *module, const char *name, unsigned int flags, configType type) { +int moduleConfigValidityCheck(ValkeyModule *module, const char *name, unsigned int flags, configType type) { if (!module->onload) { errno = EBUSY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (moduleVerifyConfigFlags(flags, type) || moduleVerifyResourceName(name)) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } if (isModuleConfigNameRegistered(module, name)) { serverLog(LL_WARNING, "Configuration by the name: %s already registered", name); errno = EALREADY; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } unsigned int maskModuleConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_DEFAULT) new_flags |= MODIFIABLE_CONFIG; - if (flags & REDISMODULE_CONFIG_IMMUTABLE) new_flags |= IMMUTABLE_CONFIG; - if (flags & REDISMODULE_CONFIG_HIDDEN) new_flags |= HIDDEN_CONFIG; - if (flags & REDISMODULE_CONFIG_PROTECTED) new_flags |= PROTECTED_CONFIG; - if (flags & REDISMODULE_CONFIG_DENY_LOADING) new_flags |= DENY_LOADING_CONFIG; + if (flags & VALKEYMODULE_CONFIG_DEFAULT) new_flags |= MODIFIABLE_CONFIG; + if (flags & VALKEYMODULE_CONFIG_IMMUTABLE) new_flags |= IMMUTABLE_CONFIG; + if (flags & VALKEYMODULE_CONFIG_HIDDEN) new_flags |= HIDDEN_CONFIG; + if (flags & VALKEYMODULE_CONFIG_PROTECTED) new_flags |= PROTECTED_CONFIG; + if (flags & VALKEYMODULE_CONFIG_DENY_LOADING) new_flags |= DENY_LOADING_CONFIG; return new_flags; } unsigned int maskModuleNumericConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_MEMORY) new_flags |= MEMORY_CONFIG; + if (flags & VALKEYMODULE_CONFIG_MEMORY) new_flags |= MEMORY_CONFIG; return new_flags; } unsigned int maskModuleEnumConfigFlags(unsigned int flags) { unsigned int new_flags = 0; - if (flags & REDISMODULE_CONFIG_BITFLAGS) new_flags |= MULTI_ARG_CONFIG; + if (flags & VALKEYMODULE_CONFIG_BITFLAGS) new_flags |= MULTI_ARG_CONFIG; return new_flags; } @@ -12805,23 +12831,23 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * Numeric: 64 bit signed integer, which also supports min and max values. * * Bool: Yes or no value. * - * 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. + * The `setfn` callback is expected to return VALKEYMODULE_OK when the value is successfully + * applied. It can also return VALKEYMODULE_ERR if the value can't be applied, and the + * *err pointer can be set with a ValkeyModuleString error message to provide to the client. + * This ValkeyModuleString 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. * The name must only contain alphanumeric characters or dashes. The supported flags are: * - * * REDISMODULE_CONFIG_DEFAULT: The default flags for a config. This creates a config that can be modified after startup. - * * REDISMODULE_CONFIG_IMMUTABLE: This config can only be provided loading time. - * * REDISMODULE_CONFIG_SENSITIVE: The value stored in this config is redacted from all logging. - * * REDISMODULE_CONFIG_HIDDEN: The name is hidden from `CONFIG GET` with pattern matching. - * * REDISMODULE_CONFIG_PROTECTED: This config will be only be modifiable based off the value of enable-protected-configs. - * * REDISMODULE_CONFIG_DENY_LOADING: This config is not modifiable while the server is loading data. - * * REDISMODULE_CONFIG_MEMORY: For numeric configs, this config will convert data unit notations into their byte equivalent. - * * REDISMODULE_CONFIG_BITFLAGS: For enum configs, this config will allow multiple entries to be combined as bit flags. + * * VALKEYMODULE_CONFIG_DEFAULT: The default flags for a config. This creates a config that can be modified after startup. + * * VALKEYMODULE_CONFIG_IMMUTABLE: This config can only be provided loading time. + * * VALKEYMODULE_CONFIG_SENSITIVE: The value stored in this config is redacted from all logging. + * * VALKEYMODULE_CONFIG_HIDDEN: The name is hidden from `CONFIG GET` with pattern matching. + * * VALKEYMODULE_CONFIG_PROTECTED: This config will be only be modifiable based off the value of enable-protected-configs. + * * VALKEYMODULE_CONFIG_DENY_LOADING: This config is not modifiable while the server is loading data. + * * VALKEYMODULE_CONFIG_MEMORY: For numeric configs, this config will convert data unit notations into their byte equivalent. + * * VALKEYMODULE_CONFIG_BITFLAGS: For enum configs, this config will allow multiple entries to be combined as bit flags. * * Default values are used on startup to set the value if it is not provided via the config file * or command line. Default values are also used to compare to on a config rewrite. @@ -12833,34 +12859,34 @@ unsigned int maskModuleEnumConfigFlags(unsigned int flags) { * * Example implementation: * - * RedisModuleString *strval; + * ValkeyModuleString *strval; * int adjustable = 1; - * RedisModuleString *getStringConfigCommand(const char *name, void *privdata) { + * ValkeyModuleString *getStringConfigCommand(const char *name, void *privdata) { * return strval; * } * - * int setStringConfigCommand(const char *name, RedisModuleString *new, void *privdata, RedisModuleString **err) { + * int setStringConfigCommand(const char *name, ValkeyModuleString *new, void *privdata, ValkeyModuleString **err) { * if (adjustable) { - * RedisModule_Free(strval); - * RedisModule_RetainString(NULL, new); + * ValkeyModule_Free(strval); + * ValkeyModule_RetainString(NULL, new); * strval = new; - * return REDISMODULE_OK; + * return VALKEYMODULE_OK; * } - * *err = RedisModule_CreateString(NULL, "Not adjustable.", 15); - * return REDISMODULE_ERR; + * *err = ValkeyModule_CreateString(NULL, "Not adjustable.", 15); + * return VALKEYMODULE_ERR; * } * ... - * RedisModule_RegisterStringConfig(ctx, "string", NULL, REDISMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); + * ValkeyModule_RegisterStringConfig(ctx, "string", NULL, VALKEYMODULE_CONFIG_DEFAULT, getStringConfigCommand, setStringConfigCommand, NULL, NULL); * - * If the registration fails, REDISMODULE_ERR is returned and one of the following + * If the registration fails, VALKEYMODULE_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 ValkeyModule_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 VM_RegisterStringConfig(ValkeyModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, ValkeyModuleConfigGetStringFunc getfn, ValkeyModuleConfigSetStringFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_string = getfn; @@ -12868,16 +12894,16 @@ int RM_RegisterStringConfig(RedisModuleCtx *ctx, const char *name, const char *d listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags); addModuleStringConfig(module->name, name, flags, new_config, default_val ? sdsnew(default_val) : NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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; + * ValkeyModule_RegisterStringConfig for detailed information about configs. */ +int VM_RegisterBoolConfig(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, ValkeyModuleConfigGetBoolFunc getfn, ValkeyModuleConfigSetBoolFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, BOOL_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_bool = getfn; @@ -12885,7 +12911,7 @@ int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags); addModuleBoolConfig(module->name, name, flags, new_config, default_val); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* @@ -12907,20 +12933,20 @@ int RM_RegisterBoolConfig(RedisModuleCtx *ctx, const char *name, int default_val * * int setEnumConfigCommand(const char *name, int val, void *privdata, const char **err) { * enum_val = val; - * return REDISMODULE_OK; + * return VALKEYMODULE_OK; * } * ... - * RedisModule_RegisterEnumConfig(ctx, "enum", 0, REDISMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); + * ValkeyModule_RegisterEnumConfig(ctx, "enum", 0, VALKEYMODULE_CONFIG_DEFAULT, enum_vals, int_vals, 3, getEnumConfigCommand, setEnumConfigCommand, NULL, NULL); * - * Note that you can use REDISMODULE_CONFIG_BITFLAGS so that multiple enum string + * Note that you can use VALKEYMODULE_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 ValkeyModule_RegisterStringConfig for detailed general information about configs. */ +int VM_RegisterEnumConfig(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, ValkeyModuleConfigGetEnumFunc getfn, ValkeyModuleConfigSetEnumFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, ENUM_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_enum = getfn; @@ -12935,17 +12961,17 @@ int RM_RegisterEnumConfig(RedisModuleCtx *ctx, const char *name, int default_val listAddNodeTail(module->module_configs, new_config); flags = maskModuleConfigFlags(flags) | maskModuleEnumConfigFlags(flags); addModuleEnumConfig(module->name, name, flags, new_config, default_val, enum_vals); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* * 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; + * ValkeyModule_RegisterStringConfig for detailed information about configs. */ +int VM_RegisterNumericConfig(ValkeyModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, ValkeyModuleConfigGetNumericFunc getfn, ValkeyModuleConfigSetNumericFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) { + ValkeyModule *module = ctx->module; if (moduleConfigValidityCheck(module, name, flags, NUMERIC_CONFIG)) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } ModuleConfig *new_config = createModuleConfig(name, applyfn, privdata, module); new_config->get_fn.get_numeric = getfn; @@ -12954,54 +12980,54 @@ int RM_RegisterNumericConfig(RedisModuleCtx *ctx, const char *name, long long de unsigned int numeric_flags = maskModuleNumericConfigFlags(flags); flags = maskModuleConfigFlags(flags); addModuleNumericConfig(module->name, name, flags, new_config, default_val, numeric_flags, min, max); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* 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 ValkeyModule_OnLoad. + * This will return VALKEYMODULE_ERR if it is called outside ValkeyModule_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 VM_LoadConfigs(ValkeyModuleCtx *ctx) { if (!ctx || !ctx->module || !ctx->module->onload) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModule *module = ctx->module; + ValkeyModule *module = ctx->module; /* Load configs from conf file or arguments from loadex */ - if (loadModuleConfigs(module)) return REDISMODULE_ERR; - return REDISMODULE_OK; + if (loadModuleConfigs(module)) return VALKEYMODULE_ERR; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- * ## RDB load/save API * -------------------------------------------------------------------------- */ -#define REDISMODULE_RDB_STREAM_FILE 1 +#define VALKEYMODULE_RDB_STREAM_FILE 1 -typedef struct RedisModuleRdbStream { +typedef struct ValkeyModuleRdbStream { int type; union { char *filename; } data; -} RedisModuleRdbStream; +} ValkeyModuleRdbStream; /* Create a stream object to save/load RDB to/from a file. * - * This function returns a pointer to RedisModuleRdbStream which is owned - * by the caller. It requires a call to RM_RdbStreamFree() to free + * This function returns a pointer to ValkeyModuleRdbStream which is owned + * by the caller. It requires a call to VM_RdbStreamFree() to free * the object. */ -RedisModuleRdbStream *RM_RdbStreamCreateFromFile(const char *filename) { - RedisModuleRdbStream *stream = zmalloc(sizeof(*stream)); - stream->type = REDISMODULE_RDB_STREAM_FILE; +ValkeyModuleRdbStream *VM_RdbStreamCreateFromFile(const char *filename) { + ValkeyModuleRdbStream *stream = zmalloc(sizeof(*stream)); + stream->type = VALKEYMODULE_RDB_STREAM_FILE; stream->data.filename = zstrdup(filename); return stream; } /* Release an RDB stream object. */ -void RM_RdbStreamFree(RedisModuleRdbStream *stream) { +void VM_RdbStreamFree(ValkeyModuleRdbStream *stream) { switch (stream->type) { - case REDISMODULE_RDB_STREAM_FILE: + case VALKEYMODULE_RDB_STREAM_FILE: zfree(stream->data.filename); break; default: @@ -13016,27 +13042,27 @@ void RM_RdbStreamFree(RedisModuleRdbStream *stream) { * * `flags` must be zero. This parameter is for future use. * - * On success REDISMODULE_OK is returned, otherwise REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_ERR is returned * and errno is set accordingly. * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbLoad(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * ValkeyModuleRdbStream *s = ValkeyModule_RdbStreamCreateFromFile("exp.rdb"); + * ValkeyModule_RdbLoad(ctx, s, 0); + * ValkeyModule_RdbStreamFree(s); */ -int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int VM_RdbLoad(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Not allowed on replicas. */ if (server.masterhost != NULL) { errno = ENOTSUP; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* Drop replicas if exist. */ @@ -13052,12 +13078,12 @@ int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { emptyData(-1,EMPTYDB_NO_FLAGS,NULL); /* rdbLoad() can go back to the networking and process network events. If - * RM_RdbLoad() is called inside a command callback, we don't want to + * VM_RdbLoad() is called inside a command callback, we don't want to * process the current client. Otherwise, we may free the client or try to * process next message while we are already in the command callback. */ if (server.current_client) protectClient(server.current_client); - serverAssert(stream->type == REDISMODULE_RDB_STREAM_FILE); + serverAssert(stream->type == VALKEYMODULE_RDB_STREAM_FILE); int ret = rdbLoad(stream->data.filename,NULL,RDBFLAGS_NONE); if (server.current_client) unprotectClient(server.current_client); @@ -13065,42 +13091,42 @@ int RM_RdbLoad(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { if (ret != RDB_OK) { errno = (ret == RDB_NOT_EXIST) ? ENOENT : EIO; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Save dataset to the RDB stream. * * `flags` must be zero. This parameter is for future use. * - * On success REDISMODULE_OK is returned, otherwise REDISMODULE_ERR is returned + * On success VALKEYMODULE_OK is returned, otherwise VALKEYMODULE_ERR is returned * and errno is set accordingly. * * Example: * - * RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb"); - * RedisModule_RdbSave(ctx, s, 0); - * RedisModule_RdbStreamFree(s); + * ValkeyModuleRdbStream *s = ValkeyModule_RdbStreamCreateFromFile("exp.rdb"); + * ValkeyModule_RdbSave(ctx, s, 0); + * ValkeyModule_RdbStreamFree(s); */ -int RM_RdbSave(RedisModuleCtx *ctx, RedisModuleRdbStream *stream, int flags) { +int VM_RdbSave(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) { UNUSED(ctx); if (!stream || flags != 0) { errno = EINVAL; - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - serverAssert(stream->type == REDISMODULE_RDB_STREAM_FILE); + serverAssert(stream->type == VALKEYMODULE_RDB_STREAM_FILE); if (rdbSaveToFile(stream->data.filename) != C_OK) { - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } errno = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Redis MODULE command. @@ -13150,7 +13176,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((ValkeyModuleString ***) &argv, &argc) == VALKEYMODULE_OK && moduleLoad(c->argv[2]->ptr, (void **)argv, argc, 1) == C_OK) addReply(c,shared.ok); else { @@ -13187,52 +13213,52 @@ 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) { + * returns VALKEYMODULE_OK if the LRU was updated, VALKEYMODULE_ERR otherwise. */ +int VM_SetLRU(ValkeyModuleKey *key, mstime_t lru_idle) { if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (objectSetLRUOrLFU(key->value, -1, lru_idle, lru_idle>=0 ? LRU_CLOCK() : 0, 1)) - return REDISMODULE_OK; - return REDISMODULE_ERR; + return VALKEYMODULE_OK; + return VALKEYMODULE_ERR; } /* Gets the key last access time. * 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) { + * returns VALKEYMODULE_OK if when key is valid. */ +int VM_GetLRU(ValkeyModuleKey *key, mstime_t *lru_idle) { *lru_idle = -1; if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) - return REDISMODULE_OK; + return VALKEYMODULE_OK; *lru_idle = estimateObjectIdleTime(key->value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Set the key access frequency. only relevant if the server's maxmemory policy * is LFU based. * 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) { + * returns VALKEYMODULE_OK if the LFU was updated, VALKEYMODULE_ERR otherwise. */ +int VM_SetLFU(ValkeyModuleKey *key, long long lfu_freq) { if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (objectSetLRUOrLFU(key->value, lfu_freq, -1, 0, 1)) - return REDISMODULE_OK; - return REDISMODULE_ERR; + return VALKEYMODULE_OK; + return VALKEYMODULE_ERR; } /* 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) { + * returns VALKEYMODULE_OK if when key is valid. */ +int VM_GetLFU(ValkeyModuleKey *key, long long *lfu_freq) { *lfu_freq = -1; if (!key->value) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (server.maxmemory_policy & MAXMEMORY_FLAG_LFU) *lfu_freq = LFUDecrAndReturn(key->value); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* -------------------------------------------------------------------------- @@ -13245,15 +13271,15 @@ int RM_GetLFU(RedisModuleKey *key, long long *lfu_freq) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetModuleOptionsAll(); - * if (supportedFlags & REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS) { - * // REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is supported + * int supportedFlags = VM_GetModuleOptionsAll(); + * if (supportedFlags & VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS) { + * // VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is supported * } else{ - * // REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is not supported + * // VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS is not supported * } */ -int RM_GetModuleOptionsAll(void) { - return _REDISMODULE_OPTIONS_FLAGS_NEXT - 1; +int VM_GetModuleOptionsAll(void) { + return _VALKEYMODULE_OPTIONS_FLAGS_NEXT - 1; } /** @@ -13262,15 +13288,15 @@ int RM_GetModuleOptionsAll(void) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetContextFlagsAll(); - * if (supportedFlags & REDISMODULE_CTX_FLAGS_MULTI) { - * // REDISMODULE_CTX_FLAGS_MULTI is supported + * int supportedFlags = VM_GetContextFlagsAll(); + * if (supportedFlags & VALKEYMODULE_CTX_FLAGS_MULTI) { + * // VALKEYMODULE_CTX_FLAGS_MULTI is supported * } else{ - * // REDISMODULE_CTX_FLAGS_MULTI is not supported + * // VALKEYMODULE_CTX_FLAGS_MULTI is not supported * } */ -int RM_GetContextFlagsAll(void) { - return _REDISMODULE_CTX_FLAGS_NEXT - 1; +int VM_GetContextFlagsAll(void) { + return _VALKEYMODULE_CTX_FLAGS_NEXT - 1; } /** @@ -13279,32 +13305,32 @@ int RM_GetContextFlagsAll(void) { * by the redis server version in use. * Example: * - * int supportedFlags = RM_GetKeyspaceNotificationFlagsAll(); - * if (supportedFlags & REDISMODULE_NOTIFY_LOADED) { - * // REDISMODULE_NOTIFY_LOADED is supported + * int supportedFlags = VM_GetKeyspaceNotificationFlagsAll(); + * if (supportedFlags & VALKEYMODULE_NOTIFY_LOADED) { + * // VALKEYMODULE_NOTIFY_LOADED is supported * } else{ - * // REDISMODULE_NOTIFY_LOADED is not supported + * // VALKEYMODULE_NOTIFY_LOADED is not supported * } */ -int RM_GetKeyspaceNotificationFlagsAll(void) { - return _REDISMODULE_NOTIFY_NEXT - 1; +int VM_GetKeyspaceNotificationFlagsAll(void) { + return _VALKEYMODULE_NOTIFY_NEXT - 1; } /** * Return the redis version in format of 0x00MMmmpp. * Example for 6.0.7 the return value will be 0x00060007. */ -int RM_GetServerVersion(void) { +int VM_GetServerVersion(void) { return SERVER_VERSION_NUM; } /** - * Return the current redis-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. + * Return the current redis-server runtime value of VALKEYMODULE_TYPE_METHOD_VERSION. + * You can use that when calling VM_CreateDataType to know which fields of + * ValkeyModuleTypeMethods are gonna be supported and which will be ignored. */ -int RM_GetTypeMethodVersion(void) { - return REDISMODULE_TYPE_METHOD_VERSION; +int VM_GetTypeMethodVersion(void) { + return VALKEYMODULE_TYPE_METHOD_VERSION; } /* Replace the value assigned to a module type. @@ -13312,10 +13338,10 @@ int RM_GetTypeMethodVersion(void) { * The key must be open for writing, have an existing value, and have a moduleType * that matches the one specified by the caller. * - * Unlike RM_ModuleTypeSetValue() which will free the old value, this function + * Unlike VM_ModuleTypeSetValue() which will free the old value, this function * simply swaps the old value with the new value. * - * The function returns REDISMODULE_OK on success, REDISMODULE_ERR on errors + * The function returns VALKEYMODULE_OK on success, VALKEYMODULE_ERR on errors * such as: * * 1. Key is not opened for writing. @@ -13324,21 +13350,21 @@ 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) { - if (!(key->mode & REDISMODULE_WRITE) || key->iter) - return REDISMODULE_ERR; +int VM_ModuleTypeReplaceValue(ValkeyModuleKey *key, moduleType *mt, void *new_value, void **old_value) { + if (!(key->mode & VALKEYMODULE_WRITE) || key->iter) + return VALKEYMODULE_ERR; if (!key->value || key->value->type != OBJ_MODULE) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; moduleValue *mv = key->value->ptr; if (mv->type != mt) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; if (old_value) *old_value = mv->value; mv->value = new_value; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* For a specified command, parse its arguments and return an array that @@ -13346,7 +13372,7 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val * essentially a more efficient way to do `COMMAND GETKEYS`. * * The out_flags argument is optional, and can be set to NULL. - * When provided it is filled with REDISMODULE_CMD_KEY_ flags in matching + * When provided it is filled with VALKEYMODULE_CMD_KEY_ flags in matching * indexes with the key indexes of the returned array. * * A NULL return value indicates the specified command has no keys, or @@ -13358,10 +13384,10 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val * * NOTE: The returned array is not a Redis Module object so it does not * get automatically freed even when auto-memory is used. The caller - * must explicitly call RM_Free() to free it, same as the out_flags pointer if + * must explicitly call VM_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 *VM_GetCommandKeysWithFlags(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys, int **out_flags) { UNUSED(ctx); struct serverCommand *cmd; int *res = NULL; @@ -13407,13 +13433,13 @@ int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, i return res; } -/* Identical to RM_GetCommandKeysWithFlags when flags are not needed. */ -int *RM_GetCommandKeys(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys) { - return RM_GetCommandKeysWithFlags(ctx, argv, argc, num_keys, NULL); +/* Identical to VM_GetCommandKeysWithFlags when flags are not needed. */ +int *VM_GetCommandKeys(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys) { + return VM_GetCommandKeysWithFlags(ctx, argv, argc, num_keys, NULL); } /* Return the name of the command currently running */ -const char *RM_GetCurrentCommandName(RedisModuleCtx *ctx) { +const char *VM_GetCurrentCommandName(ValkeyModuleCtx *ctx) { if (!ctx || !ctx->client || !ctx->client->cmd) return NULL; @@ -13427,7 +13453,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 ValkeyModuleDefragCtx { long long int endtime; unsigned long *cursor; struct serverObject *key; /* Optional name of key processed, NULL when unknown. */ @@ -13437,9 +13463,9 @@ 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 VM_RegisterDefragFunc(ValkeyModuleCtx *ctx, ValkeyModuleDefragFunc cb) { ctx->module->defrag_cb = cb; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* When the data type defrag callback iterates complex structures, this @@ -13447,8 +13473,8 @@ int RM_RegisterDefragFunc(RedisModuleCtx *ctx, RedisModuleDefragFunc cb) { * indicates the callback may continue its work. A non-zero value (true) * indicates it should stop. * - * When stopped, the callback may use RM_DefragCursorSet() to store its - * position so it can later use RM_DefragCursorGet() to resume defragging. + * When stopped, the callback may use VM_DefragCursorSet() to store its + * position so it can later use VM_DefragCursorGet() to resume defragging. * * When stopped and more work is left to be done, the callback should * return 1. Otherwise, it should return 0. @@ -13456,13 +13482,13 @@ 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 VM_DefragShouldStop(ValkeyModuleDefragCtx *ctx) { return (ctx->endtime != 0 && ctx->endtime < ustime()); } /* Store an arbitrary cursor value for future re-use. * - * This should only be called if RM_DefragShouldStop() has returned a non-zero + * This should only be called if VM_DefragShouldStop() has returned a non-zero * value and the defrag callback is about to exit without fully iterating its * data type. * @@ -13473,7 +13499,7 @@ int RM_DefragShouldStop(RedisModuleDefragCtx *ctx) { * * Smaller keys, keys that do not implement `free_effort` or the global * defrag callback are not called in late-defrag mode. In those cases, a - * call to this function will return REDISMODULE_ERR. + * call to this function will return VALKEYMODULE_ERR. * * The cursor may be used by the module to represent some progress into the * module's data type. Modules may also store additional cursor-related @@ -13482,29 +13508,29 @@ 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 VM_DefragCursorSet(ValkeyModuleDefragCtx *ctx, unsigned long cursor) { if (!ctx->cursor) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; *ctx->cursor = cursor; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Fetch a cursor value that has been previously stored using RM_DefragCursorSet(). +/* Fetch a cursor value that has been previously stored using VM_DefragCursorSet(). * - * If not called for a late defrag operation, REDISMODULE_ERR will be returned and - * the cursor should be ignored. See RM_DefragCursorSet() for more details on + * If not called for a late defrag operation, VALKEYMODULE_ERR will be returned and + * the cursor should be ignored. See VM_DefragCursorSet() for more details on * defrag cursors. */ -int RM_DefragCursorGet(RedisModuleDefragCtx *ctx, unsigned long *cursor) { +int VM_DefragCursorGet(ValkeyModuleDefragCtx *ctx, unsigned long *cursor) { if (!ctx->cursor) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; *cursor = *ctx->cursor; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -/* Defrag a memory allocation previously allocated by RM_Alloc, RM_Calloc, etc. +/* Defrag a memory allocation previously allocated by VM_Alloc, VM_Calloc, etc. * The defragmentation process involves allocating a new memory block and copying * the contents to it, like realloc(). * @@ -13515,22 +13541,22 @@ 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 *VM_DefragAlloc(ValkeyModuleDefragCtx *ctx, void *ptr) { UNUSED(ctx); return activeDefragAlloc(ptr); } -/* Defrag a RedisModuleString previously allocated by RM_Alloc, RM_Calloc, etc. - * See RM_DefragAlloc() for more information on how the defragmentation process +/* Defrag a ValkeyModuleString previously allocated by VM_Alloc, VM_Calloc, etc. + * See VM_DefragAlloc() for more information on how the defragmentation process * works. * * NOTE: It is only possible to defrag strings that have a single reference. - * Typically this means strings retained with RM_RetainString or RM_HoldString + * Typically this means strings retained with VM_RetainString or VM_HoldString * may not be defragmentable. One exception is command argvs which, if retained * 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) { +ValkeyModuleString *VM_DefragModuleString(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) { UNUSED(ctx); return activeDefragStringOb(str); } @@ -13545,7 +13571,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}; + ValkeyModuleDefragCtx 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. @@ -13594,7 +13620,7 @@ int moduleDefragValue(robj *key, robj *value, int dbid) { return 0; /* Defrag later */ } - RedisModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; + ValkeyModuleDefragCtx defrag_ctx = { 0, NULL, key, dbid }; mt->defrag(&defrag_ctx, key, &mv->value); return 1; } @@ -13605,10 +13631,10 @@ void moduleDefragGlobals(void) { dictEntry *de; while ((de = dictNext(di)) != NULL) { - struct RedisModule *module = dictGetVal(de); + struct ValkeyModule *module = dictGetVal(de); if (!module->defrag_cb) continue; - RedisModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; + ValkeyModuleDefragCtx defrag_ctx = { 0, NULL, NULL, -1}; module->defrag_cb(&defrag_ctx); } dictReleaseIterator(di); @@ -13617,14 +13643,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 ValkeyModuleString *VM_GetKeyNameFromDefragCtx(ValkeyModuleDefragCtx *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 VM_GetDbIdFromDefragCtx(ValkeyModuleDefragCtx *ctx) { return ctx->dbid; } @@ -13972,7 +13998,7 @@ void moduleRegisterCoreAPI(void) { REGISTER_API(GetTypeMethodVersion); REGISTER_API(RegisterDefragFunc); REGISTER_API(DefragAlloc); - REGISTER_API(DefragRedisModuleString); + REGISTER_API(DefragModuleString); REGISTER_API(DefragShouldStop); REGISTER_API(DefragCursorSet); REGISTER_API(DefragCursorGet); diff --git a/src/modules/Makefile b/src/modules/Makefile index b9ef5786d1..ba8c3dc169 100644 --- a/src/modules/Makefile +++ b/src/modules/Makefile @@ -25,42 +25,42 @@ all: helloworld.so hellotype.so helloblock.so hellocluster.so hellotimer.so hell .c.xo: $(CC) -I. $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@ -helloworld.xo: ../redismodule.h +helloworld.xo: ../valkeymodule.h helloworld.so: helloworld.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellotype.xo: ../redismodule.h +hellotype.xo: ../valkeymodule.h hellotype.so: hellotype.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -helloblock.xo: ../redismodule.h +helloblock.xo: ../valkeymodule.h helloblock.so: helloblock.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lpthread -lc -hellocluster.xo: ../redismodule.h +hellocluster.xo: ../valkeymodule.h hellocluster.so: hellocluster.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellotimer.xo: ../redismodule.h +hellotimer.xo: ../valkeymodule.h hellotimer.so: hellotimer.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellodict.xo: ../redismodule.h +hellodict.xo: ../valkeymodule.h hellodict.so: hellodict.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -hellohook.xo: ../redismodule.h +hellohook.xo: ../valkeymodule.h hellohook.so: hellohook.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc -helloacl.xo: ../redismodule.h +helloacl.xo: ../valkeymodule.h helloacl.so: helloacl.xo $(LD) -o $@ $^ $(SHOBJ_LDFLAGS) $(LIBS) -lc diff --git a/src/modules/helloacl.c b/src/modules/helloacl.c index 53f3a440c7..a7660afea3 100644 --- a/src/modules/helloacl.c +++ b/src/modules/helloacl.c @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include @@ -42,8 +42,8 @@ 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); if (global_auth_client_id) { RedisModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id); @@ -56,8 +56,8 @@ int RevokeCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in /* HELLOACL.RESET * Synchronously delete and re-create a module user. */ int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_FreeModuleUser(global); global = RedisModule_CreateModuleUser("global"); @@ -71,16 +71,16 @@ int ResetCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int /* Callback handler for user changes, use this to notify a module of * changes to users authenticated by the module */ void HelloACL_UserChanged(uint64_t client_id, void *privdata) { - REDISMODULE_NOT_USED(privdata); - REDISMODULE_NOT_USED(client_id); + VALKEYMODULE_NOT_USED(privdata); + VALKEYMODULE_NOT_USED(client_id); global_auth_client_id = 0; } /* HELLOACL.AUTHGLOBAL * Synchronously assigns a module user to the current context. */ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); if (global_auth_client_id) { return RedisModule_ReplyWithError(ctx, "Global user currently used"); @@ -95,15 +95,15 @@ int AuthGlobalCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv /* Reply callback for auth command HELLOACL.AUTHASYNC */ int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); size_t length; RedisModuleString *user_string = RedisModule_GetBlockedClientPrivateData(ctx); const char *name = RedisModule_StringPtrLen(user_string, &length); if (RedisModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) == - REDISMODULE_ERR) { + VALKEYMODULE_ERR) { return RedisModule_ReplyWithError(ctx, "Invalid Username or password"); } return RedisModule_ReplyWithSimpleString(ctx, "OK"); @@ -111,14 +111,14 @@ int HelloACL_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Timeout callback for auth command HELLOACL.AUTHASYNC */ int HelloACL_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx, "Request timedout"); } /* Private data frees data for HELLOACL.AUTHASYNC command. */ void HelloACL_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_FreeString(NULL, privdata); } @@ -151,33 +151,33 @@ int AuthAsyncCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, return RedisModule_ReplyWithError(ctx, "-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloacl",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.reset", - ResetCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + ResetCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.revoke", - RevokeCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + RevokeCommand_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.authglobal", - AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"helloacl.authasync", - AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; global = RedisModule_CreateModuleUser("global"); RedisModule_SetModuleUserACL(global, "allcommands"); @@ -186,5 +186,5 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) global_auth_client_id = 0; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/helloblock.c b/src/modules/helloblock.c index dc3d74975f..8c036bead5 100644 --- a/src/modules/helloblock.c +++ b/src/modules/helloblock.c @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -39,22 +39,22 @@ /* Reply callback for blocking command HELLO.BLOCK */ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); int *myint = RedisModule_GetBlockedClientPrivateData(ctx); return RedisModule_ReplyWithLongLong(ctx,*myint); } /* Timeout callback for blocking command HELLO.BLOCK */ int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLO.BLOCK command. */ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_Free(privdata); } @@ -98,11 +98,11 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a long long delay; long long timeout; - if (RedisModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[1],&delay) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } - if (RedisModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[2],&timeout) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } @@ -125,7 +125,7 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_AbortBlock(bc); return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* The thread entry point that actually executes the blocking part @@ -141,7 +141,7 @@ void *HelloKeys_ThreadMain(void *arg) { long long cursor = 0; size_t replylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); do { RedisModule_ThreadSafeContextLock(ctx); RedisModuleCallReply *reply = RedisModule_Call(ctx, @@ -178,7 +178,7 @@ void *HelloKeys_ThreadMain(void *arg) { * 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) { - REDISMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argv); if (argc != 1) return RedisModule_WrongArity(ctx); pthread_t tid; @@ -195,24 +195,24 @@ int HelloKeys_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int ar RedisModule_AbortBlock(bc); return RedisModule_ReplyWithError(ctx,"-ERR Can't start thread"); } - return REDISMODULE_OK; + return VALKEYMODULE_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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloblock",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.block", - HelloBlock_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloBlock_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.keys", - HelloKeys_RedisCommand,"",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloKeys_RedisCommand,"",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellocluster.c b/src/modules/hellocluster.c index bc145c2b22..7a70332ada 100644 --- a/src/modules/hellocluster.c +++ b/src/modules/hellocluster.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -41,8 +41,8 @@ /* HELLOCLUSTER.PINGALL */ int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3); return RedisModule_ReplyWithSimpleString(ctx, "OK"); @@ -50,8 +50,8 @@ int PingallCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i /* HELLOCLUSTER.LIST */ int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); size_t numnodes; char **ids = RedisModule_GetClusterNodesList(ctx,&numnodes); @@ -64,17 +64,17 @@ int ListCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int 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_ReplyWithStringBuffer(ctx,ids[j],VALKEYMODULE_NODE_ID_LEN); RedisModule_ReplyWithLongLong(ctx,port); } RedisModule_FreeClusterNodesList(ids); - return REDISMODULE_OK; + return VALKEYMODULE_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'", - type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); + type,VALKEYMODULE_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); @@ -83,25 +83,25 @@ void PingReceiver(RedisModuleCtx *ctx, const char *sender_id, uint8_t type, cons /* 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'", - type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload); + type,VALKEYMODULE_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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellocluster",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellocluster.pingall", - PingallCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + PingallCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellocluster.list", - ListCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + ListCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Disable Redis Cluster sharding and redirections. This way every node * will be able to access every possible key, regardless of the hash slot. @@ -109,10 +109,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); + RedisModule_SetClusterFlags(ctx,VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION); /* Register our handlers for different message types. */ RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver); RedisModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellodict.c b/src/modules/hellodict.c index 12b6e91d25..6a6420b7d3 100644 --- a/src/modules/hellodict.c +++ b/src/modules/hellodict.c @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -76,7 +76,7 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Parse the count argument. */ long long count; - if (RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) { + if (RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); } @@ -88,10 +88,10 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { char *key; size_t keylen; long long replylen = 0; /* Keep track of the emitted array len. */ - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); while((key = RedisModule_DictNextC(iter,&keylen,NULL)) != NULL) { if (replylen >= count) break; - if (RedisModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR) + if (RedisModule_DictCompare(iter,"<=",argv[2]) == VALKEYMODULE_ERR) break; RedisModule_ReplyWithStringBuffer(ctx,key,keylen); replylen++; @@ -100,32 +100,32 @@ int cmd_KEYRANGE(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Cleanup. */ RedisModule_DictIteratorStop(iter); - return REDISMODULE_OK; + return VALKEYMODULE_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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellodict",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.set", - cmd_SET,"write deny-oom",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_SET,"write deny-oom",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.get", - cmd_GET,"readonly",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_GET,"readonly",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellodict.keyrange", - cmd_KEYRANGE,"readonly",1,1,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + cmd_KEYRANGE,"readonly",1,1,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Create our global dictionary. Here we'll set our keys and values. */ Keyspace = RedisModule_CreateDict(NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellohook.c b/src/modules/hellohook.c index 2859a8b26a..4b675891a2 100644 --- a/src/modules/hellohook.c +++ b/src/modules/hellohook.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -39,23 +39,23 @@ /* Client state change callback. */ void clientChangeCallback(RedisModuleCtx *ctx, RedisModuleEvent e, uint64_t sub, void *data) { - REDISMODULE_NOT_USED(ctx); - REDISMODULE_NOT_USED(e); + VALKEYMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(e); RedisModuleClientInfo *ci = data; printf("Client %s event for client #%llu %s:%d\n", - (sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ? + (sub == VALKEYMODULE_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) { - REDISMODULE_NOT_USED(ctx); - REDISMODULE_NOT_USED(e); + VALKEYMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(e); RedisModuleFlushInfo *fi = data; - if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) { + if (sub == VALKEYMODULE_SUBEVENT_FLUSHDB_START) { if (fi->dbnum != -1) { RedisModuleCallReply *reply; reply = RedisModule_Call(ctx,"DBSIZE",""); @@ -78,15 +78,15 @@ 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellohook",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_ClientChange, clientChangeCallback); RedisModule_SubscribeToServerEvent(ctx, RedisModuleEvent_FlushDB, flushdbCallback); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellotimer.c b/src/modules/hellotimer.c index 67e1e67143..d0ea4e14a9 100644 --- a/src/modules/hellotimer.c +++ b/src/modules/hellotimer.c @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -38,22 +38,22 @@ /* Timer callback. */ void timerHandler(RedisModuleCtx *ctx, void *data) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); printf("Fired %s!\n", (char *)data); RedisModule_Free(data); } /* HELLOTIMER.TIMER*/ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); for (int j = 0; j < 10; j++) { int delay = rand() % 5000; char *buf = RedisModule_Alloc(256); snprintf(buf,256,"After %d", delay); RedisModuleTimerID tid = RedisModule_CreateTimer(ctx,delay,timerHandler,buf); - REDISMODULE_NOT_USED(tid); + VALKEYMODULE_NOT_USED(tid); } return RedisModule_ReplyWithSimpleString(ctx, "OK"); } @@ -61,15 +61,15 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellotimer",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotimer.timer", - TimerCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + TimerCommand_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/hellotype.c b/src/modules/hellotype.c index 1dc53d24c1..31ca35f6f5 100644 --- a/src/modules/hellotype.c +++ b/src/modules/hellotype.c @@ -35,7 +35,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -105,22 +105,22 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 3) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long value; - if ((RedisModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) { + if ((RedisModule_StringToLongLong(argv[2],&value) != VALKEYMODULE_OK)) { return RedisModule_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) { + if (type == VALKEYMODULE_KEYTYPE_EMPTY) { hto = createHelloTypeObject(); RedisModule_ModuleTypeSetValue(key,HelloType,hto); } else { @@ -133,7 +133,7 @@ int HelloTypeInsert_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_ReplyWithLongLong(ctx,hto->len); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLOTYPE.RANGE key first count */ @@ -142,17 +142,17 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long first, count; - if (RedisModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK || - RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK || + if (RedisModule_StringToLongLong(argv[2],&first) != VALKEYMODULE_OK || + RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK || first < 0 || count < 0) { return RedisModule_ReplyWithError(ctx, @@ -161,7 +161,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); struct HelloTypeNode *node = hto ? hto->head : NULL; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); long long arraylen = 0; while(node && count--) { RedisModule_ReplyWithLongLong(ctx,node->value); @@ -169,7 +169,7 @@ int HelloTypeRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i node = node->next; } RedisModule_ReplySetArrayLength(ctx,arraylen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLOTYPE.LEN key */ @@ -178,17 +178,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int if (argc != 2) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } struct HelloTypeObject *hto = RedisModule_ModuleTypeGetValue(key); RedisModule_ReplyWithLongLong(ctx,hto ? hto->len : 0); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* ====================== Example of a blocking command ==================== */ @@ -197,17 +197,17 @@ int HelloTypeLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int * 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModuleString *keyname = RedisModule_GetBlockedClientReadyKey(ctx); - RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,REDISMODULE_READ); + RedisModuleKey *key = RedisModule_OpenKey(ctx,keyname,VALKEYMODULE_READ); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_MODULE || + if (type != VALKEYMODULE_KEYTYPE_MODULE || RedisModule_ModuleTypeGetType(key) != HelloType) { RedisModule_CloseKey(key); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } /* In case the key is able to serve our blocked client, let's directly @@ -218,14 +218,14 @@ int HelloBlock_Reply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { /* Timeout callback for blocking command HELLOTYPE.BRANGE */ int HelloBlock_Timeout(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); return RedisModule_ReplyWithSimpleString(ctx,"Request timedout"); } /* Private data freeing callback for HELLOTYPE.BRANGE command. */ void HelloBlock_FreeData(RedisModuleCtx *ctx, void *privdata) { - REDISMODULE_NOT_USED(ctx); + VALKEYMODULE_NOT_USED(ctx); RedisModule_Free(privdata); } @@ -236,31 +236,31 @@ int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 5) return RedisModule_WrongArity(ctx); RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_EMPTY && + if (type != VALKEYMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != HelloType) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_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) { + if (RedisModule_StringToLongLong(argv[4],&timeout) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx, "ERR invalid timeout parameter"); } /* Can we serve the reply synchronously? */ - if (type != REDISMODULE_KEYTYPE_EMPTY) { + if (type != VALKEYMODULE_KEYTYPE_EMPTY) { return HelloTypeRange_RedisCommand(ctx,argv,argc-1); } /* 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); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* ========================== "hellotype" type methods ======================= */ @@ -323,14 +323,14 @@ void HelloTypeDigest(RedisModuleDigest *md, void *value) { /* 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); - if (RedisModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"hellotype",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; RedisModuleTypeMethods tm = { - .version = REDISMODULE_TYPE_METHOD_VERSION, + .version = VALKEYMODULE_TYPE_METHOD_VERSION, .rdb_load = HelloTypeRdbLoad, .rdb_save = HelloTypeRdbSave, .aof_rewrite = HelloTypeAofRewrite, @@ -340,23 +340,23 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) }; HelloType = RedisModule_CreateDataType(ctx,"hellotype",0,&tm); - if (HelloType == NULL) return REDISMODULE_ERR; + if (HelloType == NULL) return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.insert", - HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.range", - HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.len", - HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hellotype.brange", - HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloTypeBRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/modules/helloworld.c b/src/modules/helloworld.c index e517963101..658bcb3926 100644 --- a/src/modules/helloworld.c +++ b/src/modules/helloworld.c @@ -34,7 +34,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "../redismodule.h" +#include "../valkeymodule.h" #include #include #include @@ -46,10 +46,10 @@ * 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) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_ReplyWithLongLong(ctx,RedisModule_GetSelectedDb(ctx)); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.NATIVE re-implements RPUSH, and shows the low level modules API @@ -63,13 +63,13 @@ int HelloPushNative_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 3) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); - RedisModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]); + RedisModule_ListPush(key,VALKEYMODULE_LIST_TAIL,argv[2]); size_t newlen = RedisModule_ValueLength(key); RedisModule_CloseKey(key); RedisModule_ReplyWithLongLong(ctx,newlen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling @@ -87,7 +87,7 @@ int HelloPushCall_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in long long len = RedisModule_CallReplyInteger(reply); RedisModule_FreeCallReply(reply); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.PUSH.CALL2 @@ -102,7 +102,7 @@ int HelloPushCall2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i reply = RedisModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]); RedisModule_ReplyWithCallReply(ctx,reply); RedisModule_FreeCallReply(reply); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LIST.SUM.LEN returns the total length of all the items inside @@ -124,7 +124,7 @@ int HelloListSumLen_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, } RedisModule_FreeCallReply(reply); RedisModule_ReplyWithLongLong(ctx,strlen); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LIST.SPLICE srclist dstlist count @@ -135,23 +135,23 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_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 ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) || + (RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY)) { RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) || (count < 0)) { RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); @@ -161,9 +161,9 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, while(count-- > 0) { RedisModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele); RedisModule_FreeString(ctx,ele); } @@ -171,7 +171,7 @@ int HelloListSplice_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_CloseKey(srckey); RedisModule_CloseKey(dstkey); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Like the HELLO.LIST.SPLICE above, but uses automatic memory management @@ -182,21 +182,21 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar RedisModule_AutoMemory(ctx); RedisModuleKey *srckey = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); RedisModuleKey *dstkey = RedisModule_OpenKey(ctx,argv[2], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_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 ((RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(srckey) != VALKEYMODULE_KEYTYPE_EMPTY) || + (RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_LIST && + RedisModule_KeyType(dstkey) != VALKEYMODULE_KEYTYPE_EMPTY)) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } long long count; - if ((RedisModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[3],&count) != VALKEYMODULE_OK) || (count < 0)) { return RedisModule_ReplyWithError(ctx,"ERR invalid count"); @@ -205,14 +205,14 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar while(count-- > 0) { RedisModuleString *ele; - ele = RedisModule_ListPop(srckey,REDISMODULE_LIST_TAIL); + ele = RedisModule_ListPop(srckey,VALKEYMODULE_LIST_TAIL); if (ele == NULL) break; - RedisModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele); + RedisModule_ListPush(dstkey,VALKEYMODULE_LIST_HEAD,ele); } size_t len = RedisModule_ValueLength(srckey); RedisModule_ReplyWithLongLong(ctx,len); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.RAND.ARRAY @@ -221,7 +221,7 @@ int HelloListSpliceAuto_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **ar int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (argc != 2) return RedisModule_WrongArity(ctx); long long count; - if (RedisModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK || + if (RedisModule_StringToLongLong(argv[1],&count) != VALKEYMODULE_OK || count < 0) return RedisModule_ReplyWithError(ctx,"ERR invalid count"); @@ -230,7 +230,7 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i * the elements of the array. */ RedisModule_ReplyWithArray(ctx,count); while(count--) RedisModule_ReplyWithLongLong(ctx,rand()); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is a simple command to test replication. Because of the "!" modified @@ -239,8 +239,8 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i * comments the function implementation). */ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { - REDISMODULE_NOT_USED(argv); - REDISMODULE_NOT_USED(argc); + VALKEYMODULE_NOT_USED(argv); + VALKEYMODULE_NOT_USED(argc); RedisModule_AutoMemory(ctx); /* This will be replicated *after* the two INCR statements, since @@ -262,7 +262,7 @@ int HelloRepl1_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_ReplyWithLongLong(ctx,0); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* Another command to show replication. In this case, we call @@ -280,27 +280,27 @@ int HelloRepl2_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a RedisModule_AutoMemory(ctx); /* Use automatic memory management. */ RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST) - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_LIST) + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); size_t listlen = RedisModule_ValueLength(key); long long sum = 0; /* Rotate and increment. */ while(listlen--) { - RedisModuleString *ele = RedisModule_ListPop(key,REDISMODULE_LIST_TAIL); + RedisModuleString *ele = RedisModule_ListPop(key,VALKEYMODULE_LIST_TAIL); long long val; - if (RedisModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0; + if (RedisModule_StringToLongLong(ele,&val) != VALKEYMODULE_OK) val = 0; val++; sum += val; RedisModuleString *newele = RedisModule_CreateStringFromLongLong(ctx,val); - RedisModule_ListPush(key,REDISMODULE_LIST_HEAD,newele); + RedisModule_ListPush(key,VALKEYMODULE_LIST_HEAD,newele); } RedisModule_ReplyWithLongLong(ctx,sum); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* This is an example of strings DMA access. Given a key containing a string @@ -315,19 +315,19 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, if (argc != 2) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int keytype = RedisModule_KeyType(key); - if (keytype != REDISMODULE_KEYTYPE_STRING && - keytype != REDISMODULE_KEYTYPE_EMPTY) + if (keytype != VALKEYMODULE_KEYTYPE_STRING && + keytype != VALKEYMODULE_KEYTYPE_EMPTY) { RedisModule_CloseKey(key); - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } - if (keytype == REDISMODULE_KEYTYPE_STRING) { + if (keytype == VALKEYMODULE_KEYTYPE_STRING) { size_t len, j; - char *s = RedisModule_StringDMA(key,&len,REDISMODULE_WRITE); + char *s = RedisModule_StringDMA(key,&len,VALKEYMODULE_WRITE); for (j = 0; j < len; j++) { if (isupper(s[j])) { s[j] = tolower(s[j]); @@ -340,7 +340,7 @@ int HelloToggleCase_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, RedisModule_CloseKey(key); RedisModule_ReplyWithSimpleString(ctx,"OK"); RedisModule_ReplicateVerbatim(ctx); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.MORE.EXPIRE key milliseconds. @@ -353,13 +353,13 @@ int HelloMoreExpire_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, mstime_t addms, expire; - if (RedisModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK) + if (RedisModule_StringToLongLong(argv[2],&addms) != VALKEYMODULE_OK) return RedisModule_ReplyWithError(ctx,"ERR invalid expire time"); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); expire = RedisModule_GetExpire(key); - if (expire != REDISMODULE_NO_EXPIRE) { + if (expire != VALKEYMODULE_NO_EXPIRE) { expire += addms; RedisModule_SetExpire(key,expire); } @@ -376,16 +376,16 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i double score_start, score_end; if (argc != 4) return RedisModule_WrongArity(ctx); - if (RedisModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK || - RedisModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK) + if (RedisModule_StringToDouble(argv[2],&score_start) != VALKEYMODULE_OK || + RedisModule_StringToDouble(argv[3],&score_end) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"ERR invalid range"); } RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) { + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } double scoresum_a = 0; @@ -417,7 +417,7 @@ int HelloZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i RedisModule_ReplyWithArray(ctx,2); RedisModule_ReplyWithDouble(ctx,scoresum_a); RedisModule_ReplyWithDouble(ctx,scoresum_b); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LEXRANGE key min_lex max_lex min_age max_age @@ -433,17 +433,17 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in if (argc != 6) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); - if (RedisModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); + if (RedisModule_KeyType(key) != VALKEYMODULE_KEYTYPE_ZSET) { + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } - if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) { + if (RedisModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != VALKEYMODULE_OK) { return RedisModule_ReplyWithError(ctx,"invalid range"); } int arraylen = 0; - RedisModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN); + RedisModule_ReplyWithArray(ctx,VALKEYMODULE_POSTPONED_LEN); while(!RedisModule_ZsetRangeEndReached(key)) { double score; RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(key,&score); @@ -455,7 +455,7 @@ int HelloLexRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, in RedisModule_ZsetRangeStop(key); RedisModule_ReplySetArrayLength(ctx,arraylen); RedisModule_CloseKey(key); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.HCOPY key srcfield dstfield @@ -470,22 +470,22 @@ int HelloHCopy_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a if (argc != 4) return RedisModule_WrongArity(ctx); RedisModuleKey *key = RedisModule_OpenKey(ctx,argv[1], - REDISMODULE_READ|REDISMODULE_WRITE); + VALKEYMODULE_READ|VALKEYMODULE_WRITE); int type = RedisModule_KeyType(key); - if (type != REDISMODULE_KEYTYPE_HASH && - type != REDISMODULE_KEYTYPE_EMPTY) + if (type != VALKEYMODULE_KEYTYPE_HASH && + type != VALKEYMODULE_KEYTYPE_EMPTY) { - return RedisModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE); + return RedisModule_ReplyWithError(ctx,VALKEYMODULE_ERRORMSG_WRONGTYPE); } /* Get the old field value. */ RedisModuleString *oldval; - RedisModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL); + RedisModule_HashGet(key,VALKEYMODULE_HASH_NONE,argv[2],&oldval,NULL); if (oldval) { - RedisModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL); + RedisModule_HashSet(key,VALKEYMODULE_HASH_NONE,argv[3],oldval,NULL); } RedisModule_ReplyWithLongLong(ctx,oldval != NULL); - return REDISMODULE_OK; + return VALKEYMODULE_OK; } /* HELLO.LEFTPAD str len ch @@ -512,7 +512,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int if (argc != 4) return RedisModule_WrongArity(ctx); - if ((RedisModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) || + if ((RedisModule_StringToLongLong(argv[2],&padlen) != VALKEYMODULE_OK) || (padlen< 0)) { return RedisModule_ReplyWithError(ctx,"ERR invalid padding length"); } @@ -537,14 +537,14 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int memcpy(buf+padlen,str,strlen); RedisModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen); - return REDISMODULE_OK; + return VALKEYMODULE_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) - == REDISMODULE_ERR) return REDISMODULE_ERR; + if (RedisModule_Init(ctx,"helloworld",1,VALKEYMODULE_APIVER_1) + == VALKEYMODULE_ERR) return VALKEYMODULE_ERR; /* Log the list of parameters passing loading the module. */ for (int j = 0; j < argc; j++) { @@ -553,69 +553,69 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) } if (RedisModule_CreateCommand(ctx,"hello.simple", - HelloSimple_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloSimple_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.native", - HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.call", - HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushCall_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.push.call2", - HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloPushCall2_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.sum.len", - HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloListSumLen_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.splice", - HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.list.splice.auto", HelloListSpliceAuto_RedisCommand, - "write deny-oom",1,2,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + "write deny-oom",1,2,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.rand.array", - HelloRandArray_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRandArray_RedisCommand,"readonly",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.repl1", - HelloRepl1_RedisCommand,"write",0,0,0) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRepl1_RedisCommand,"write",0,0,0) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.repl2", - HelloRepl2_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloRepl2_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.toggle.case", - HelloToggleCase_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloToggleCase_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.more.expire", - HelloMoreExpire_RedisCommand,"write",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloMoreExpire_RedisCommand,"write",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.zsumrange", - HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloZsumRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.lexrange", - HelloLexRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloLexRange_RedisCommand,"readonly",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.hcopy", - HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; if (RedisModule_CreateCommand(ctx,"hello.leftpad", - HelloLeftPad_RedisCommand,"",1,1,1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + HelloLeftPad_RedisCommand,"",1,1,1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } diff --git a/src/networking.c b/src/networking.c index 0adbfeb452..e8998dc1ad 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1309,8 +1309,8 @@ void clientAcceptHandler(connection *conn) { } server.stat_numconnections++; - moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE, - REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE, + VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED, c); } @@ -1574,8 +1574,8 @@ void freeClient(client *c) { /* For connected clients, call the disconnection event of modules hooks. */ if (c->conn) { - moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE, - REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_CLIENT_CHANGE, + VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED, c); } @@ -1695,8 +1695,8 @@ void freeClient(client *c) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ if (c->replstate == SLAVE_STATE_ONLINE) - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE, NULL); } diff --git a/src/rdb.c b/src/rdb.c index 052d780d02..1c922d31bb 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1079,7 +1079,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; + ValkeyModuleIO io; moduleValue *mv = o->ptr; moduleType *mt = mv->type; @@ -1217,7 +1217,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; + ValkeyModuleIO io; int retval = 0; moduleInitIOContext(io,mt,rdb,NULL,-1); @@ -1397,7 +1397,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) { snprintf(magic,sizeof(magic),"REDIS%04d",RDB_VERSION); if (rdbWriteRaw(rdb,magic,9) == -1) goto werr; if (rdbSaveInfoAuxFields(rdb,rdbflags,rsi) == -1) goto werr; - if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_BEFORE_RDB) == -1) goto werr; + if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_BEFORE_RDB) == -1) goto werr; /* save functions */ if (!(req & SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS) && rdbSaveFunctions(rdb) == -1) goto werr; @@ -1409,7 +1409,7 @@ int rdbSaveRio(int req, rio *rdb, int *error, int rdbflags, rdbSaveInfo *rsi) { } } - if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, REDISMODULE_AUX_AFTER_RDB) == -1) goto werr; + if (!(req & SLAVE_REQ_RDB_EXCLUDE_DATA) && rdbSaveModulesAux(rdb, VALKEYMODULE_AUX_AFTER_RDB) == -1) goto werr; /* EOF opcode */ if (rdbSaveType(rdb,RDB_OPCODE_EOF) == -1) goto werr; @@ -2814,7 +2814,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; + ValkeyModuleIO io; robj keyobj; initStaticStringObject(keyobj,key); moduleInitIOContext(io,mt,rdb,&keyobj,dbid); @@ -2881,12 +2881,12 @@ void startLoading(size_t size, int rdbflags, int async) { /* Fire the loading modules start event. */ int subevent; if (rdbflags & RDBFLAGS_AOF_PREAMBLE) - subevent = REDISMODULE_SUBEVENT_LOADING_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_LOADING_AOF_START; else if(rdbflags & RDBFLAGS_REPLICATION) - subevent = REDISMODULE_SUBEVENT_LOADING_REPL_START; + subevent = VALKEYMODULE_SUBEVENT_LOADING_REPL_START; else - subevent = REDISMODULE_SUBEVENT_LOADING_RDB_START; - moduleFireServerEvent(REDISMODULE_EVENT_LOADING,subevent,NULL); + subevent = VALKEYMODULE_SUBEVENT_LOADING_RDB_START; + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING,subevent,NULL); } /* Mark that we are loading in the global state and setup the fields @@ -2924,10 +2924,10 @@ void stopLoading(int success) { rdbFileBeingLoaded = NULL; /* Fire the loading modules end event. */ - moduleFireServerEvent(REDISMODULE_EVENT_LOADING, + moduleFireServerEvent(VALKEYMODULE_EVENT_LOADING, success? - REDISMODULE_SUBEVENT_LOADING_ENDED: - REDISMODULE_SUBEVENT_LOADING_FAILED, + VALKEYMODULE_SUBEVENT_LOADING_ENDED: + VALKEYMODULE_SUBEVENT_LOADING_FAILED, NULL); } @@ -2935,22 +2935,22 @@ void startSaving(int rdbflags) { /* Fire the persistence modules start event. */ int subevent; if (rdbflags & RDBFLAGS_AOF_PREAMBLE && getpid() != server.pid) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START; else if (rdbflags & RDBFLAGS_AOF_PREAMBLE) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START; else if (getpid()!=server.pid) - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START; + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START; else - subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START; - moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,subevent,NULL); + subevent = VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START; + moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE,subevent,NULL); } void stopSaving(int success) { /* Fire the persistence modules end event. */ - moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE, + moduleFireServerEvent(VALKEYMODULE_EVENT_PERSISTENCE, success? - REDISMODULE_SUBEVENT_PERSISTENCE_ENDED: - REDISMODULE_SUBEVENT_PERSISTENCE_FAILED, + VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED: + VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED, NULL); } @@ -3224,7 +3224,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin exit(1); } - RedisModuleIO io; + ValkeyModuleIO 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. */ @@ -3233,7 +3233,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin moduleFreeContext(io.ctx); zfree(io.ctx); } - if (rc != REDISMODULE_OK || io.error) { + if (rc != VALKEYMODULE_OK || io.error) { moduleTypeNameByID(name,moduleid); serverLog(LL_WARNING,"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.", name); goto eoferr; diff --git a/src/redismodule.h b/src/redismodule.h index 8b5d2beb65..f9ecaf5868 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -1,1695 +1,723 @@ -#ifndef REDISMODULE_H -#define REDISMODULE_H - -#include -#include -#include -#include - - -typedef struct RedisModuleString RedisModuleString; -typedef struct RedisModuleKey RedisModuleKey; - -/* -------------- Defines NOT common between core and modules ------------- */ - -#if defined REDISMODULE_CORE -/* Things only defined for the modules core (server), not exported to modules - * that include this file. */ - -#define RedisModuleString robj - -#endif /* defined REDISMODULE_CORE */ - -#if !defined REDISMODULE_CORE && !defined REDISMODULE_CORE_MODULE -/* Things defined for modules, but not for core-modules. */ - -typedef long long mstime_t; -typedef long long ustime_t; - -#endif /* !defined REDISMODULE_CORE && !defined REDISMODULE_CORE_MODULE */ - -/* ---------------- Defines common between core and modules --------------- */ - -/* Error status return values. */ -#define REDISMODULE_OK 0 -#define REDISMODULE_ERR 1 - -/* Module Based Authentication status return values. */ -#define REDISMODULE_AUTH_HANDLED 0 -#define REDISMODULE_AUTH_NOT_HANDLED 1 - -/* API versions. */ -#define REDISMODULE_APIVER_1 1 - -/* Version of the RedisModuleTypeMethods structure. Once the RedisModuleTypeMethods - * structure is changed, this version number needs to be changed synchronistically. */ -#define REDISMODULE_TYPE_METHOD_VERSION 5 - -/* API flags and constants */ -#define REDISMODULE_READ (1<<0) -#define REDISMODULE_WRITE (1<<1) - -/* RedisModule_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. */ -#define REDISMODULE_OPEN_KEY_NONOTIFY (1<<17) -/* Don't update keyspace hits/misses counters. */ -#define REDISMODULE_OPEN_KEY_NOSTATS (1<<18) -/* Avoid deleting lazy expired keys. */ -#define REDISMODULE_OPEN_KEY_NOEXPIRE (1<<19) -/* Avoid any effects from fetching the key */ -#define REDISMODULE_OPEN_KEY_NOEFFECTS (1<<20) -/* Mask of all REDISMODULE_OPEN_KEY_* values. Any new mode should be added to this list. - * Should not be used directly by the module, use RM_GetOpenKeyModesAll instead. - * Located here so when we will add new modes we will not forget to update it. */ -#define _REDISMODULE_OPEN_KEY_ALL REDISMODULE_READ | REDISMODULE_WRITE | REDISMODULE_OPEN_KEY_NOTOUCH | REDISMODULE_OPEN_KEY_NONOTIFY | REDISMODULE_OPEN_KEY_NOSTATS | REDISMODULE_OPEN_KEY_NOEXPIRE | REDISMODULE_OPEN_KEY_NOEFFECTS - -/* List push and pop */ -#define REDISMODULE_LIST_HEAD 0 -#define REDISMODULE_LIST_TAIL 1 - -/* Key types. */ -#define REDISMODULE_KEYTYPE_EMPTY 0 -#define REDISMODULE_KEYTYPE_STRING 1 -#define REDISMODULE_KEYTYPE_LIST 2 -#define REDISMODULE_KEYTYPE_HASH 3 -#define REDISMODULE_KEYTYPE_SET 4 -#define REDISMODULE_KEYTYPE_ZSET 5 -#define REDISMODULE_KEYTYPE_MODULE 6 -#define REDISMODULE_KEYTYPE_STREAM 7 - -/* Reply types. */ -#define REDISMODULE_REPLY_UNKNOWN -1 -#define REDISMODULE_REPLY_STRING 0 -#define REDISMODULE_REPLY_ERROR 1 -#define REDISMODULE_REPLY_INTEGER 2 -#define REDISMODULE_REPLY_ARRAY 3 -#define REDISMODULE_REPLY_NULL 4 -#define REDISMODULE_REPLY_MAP 5 -#define REDISMODULE_REPLY_SET 6 -#define REDISMODULE_REPLY_BOOL 7 -#define REDISMODULE_REPLY_DOUBLE 8 -#define REDISMODULE_REPLY_BIG_NUMBER 9 -#define REDISMODULE_REPLY_VERBATIM_STRING 10 -#define REDISMODULE_REPLY_ATTRIBUTE 11 -#define REDISMODULE_REPLY_PROMISE 12 - -/* Postponed array length. */ -#define REDISMODULE_POSTPONED_ARRAY_LEN -1 /* Deprecated, please use REDISMODULE_POSTPONED_LEN */ -#define REDISMODULE_POSTPONED_LEN -1 - -/* Expire */ -#define REDISMODULE_NO_EXPIRE -1 - -/* Sorted set API flags. */ -#define REDISMODULE_ZADD_XX (1<<0) -#define REDISMODULE_ZADD_NX (1<<1) -#define REDISMODULE_ZADD_ADDED (1<<2) -#define REDISMODULE_ZADD_UPDATED (1<<3) -#define REDISMODULE_ZADD_NOP (1<<4) -#define REDISMODULE_ZADD_GT (1<<5) -#define REDISMODULE_ZADD_LT (1<<6) - -/* Hash API flags. */ -#define REDISMODULE_HASH_NONE 0 -#define REDISMODULE_HASH_NX (1<<0) -#define REDISMODULE_HASH_XX (1<<1) -#define REDISMODULE_HASH_CFIELDS (1<<2) -#define REDISMODULE_HASH_EXISTS (1<<3) -#define REDISMODULE_HASH_COUNT_ALL (1<<4) - -#define REDISMODULE_CONFIG_DEFAULT 0 /* This is the default for a module config. */ -#define REDISMODULE_CONFIG_IMMUTABLE (1ULL<<0) /* Can this value only be set at startup? */ -#define REDISMODULE_CONFIG_SENSITIVE (1ULL<<1) /* Does this value contain sensitive information */ -#define REDISMODULE_CONFIG_HIDDEN (1ULL<<4) /* This config is hidden in `config get ` (used for tests/debugging) */ -#define REDISMODULE_CONFIG_PROTECTED (1ULL<<5) /* Becomes immutable if enable-protected-configs is enabled. */ -#define REDISMODULE_CONFIG_DENY_LOADING (1ULL<<6) /* This config is forbidden during loading. */ - -#define REDISMODULE_CONFIG_MEMORY (1ULL<<7) /* Indicates if this value can be set as a memory value */ -#define REDISMODULE_CONFIG_BITFLAGS (1ULL<<8) /* Indicates if this value can be set as a multiple enum values */ - -/* StreamID type. */ -typedef struct RedisModuleStreamID { - uint64_t ms; - uint64_t seq; -} RedisModuleStreamID; - -/* StreamAdd() flags. */ -#define REDISMODULE_STREAM_ADD_AUTOID (1<<0) -/* StreamIteratorStart() flags. */ -#define REDISMODULE_STREAM_ITERATOR_EXCLUSIVE (1<<0) -#define REDISMODULE_STREAM_ITERATOR_REVERSE (1<<1) -/* StreamIteratorTrim*() flags. */ -#define REDISMODULE_STREAM_TRIM_APPROX (1<<0) - -/* Context Flags: Info about the current context returned by - * RM_GetContextFlags(). */ - -/* The command is running in the context of a Lua script */ -#define REDISMODULE_CTX_FLAGS_LUA (1<<0) -/* The command is running inside a Redis transaction */ -#define REDISMODULE_CTX_FLAGS_MULTI (1<<1) -/* The instance is a master */ -#define REDISMODULE_CTX_FLAGS_MASTER (1<<2) -/* The instance is a slave */ -#define REDISMODULE_CTX_FLAGS_SLAVE (1<<3) -/* The instance is read-only (usually meaning it's a slave as well) */ -#define REDISMODULE_CTX_FLAGS_READONLY (1<<4) -/* The instance is running in cluster mode */ -#define REDISMODULE_CTX_FLAGS_CLUSTER (1<<5) -/* The instance has AOF enabled */ -#define REDISMODULE_CTX_FLAGS_AOF (1<<6) -/* The instance has RDB enabled */ -#define REDISMODULE_CTX_FLAGS_RDB (1<<7) -/* The instance has Maxmemory set */ -#define REDISMODULE_CTX_FLAGS_MAXMEMORY (1<<8) -/* Maxmemory is set and has an eviction policy that may delete keys */ -#define REDISMODULE_CTX_FLAGS_EVICT (1<<9) -/* Redis is out of memory according to the maxmemory flag. */ -#define REDISMODULE_CTX_FLAGS_OOM (1<<10) -/* Less than 25% of memory available according to maxmemory. */ -#define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11) -/* The command was sent over the replication link. */ -#define REDISMODULE_CTX_FLAGS_REPLICATED (1<<12) -/* Redis is currently loading either from AOF or RDB. */ -#define REDISMODULE_CTX_FLAGS_LOADING (1<<13) -/* The replica has no link with its master, note that - * there is the inverse flag as well: +/* + * RedisModule Compatibility Header - Snapshot for Redis 7.2.4 * - * REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE + * This header file facilitates backward compatibility for existing Redis modules + * by mapping legacy REDISMODULE_* prefixed macros and identifiers to their + * new equivalents prefixed with VALKEYMODULE_*. It acts as an adapter allowing + * modules written for the older REDISMODULE API to compile and function correctly + * with the newer VALKEYMODULE API without requiring source code changes. New modules + * should be developed using "valkeymodule.h" instead. * - * The two flags are exclusive, one or the other can be set. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14) -/* The replica is trying to connect with the master. - * (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15) -/* THe replica is receiving an RDB file from its master. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16) -/* The replica is online, receiving updates from its master. */ -#define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17) -/* There is currently some background process active. */ -#define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18) -/* The next EXEC will fail due to dirty CAS (touched keys). */ -#define REDISMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19) -/* Redis is currently running inside background child process. */ -#define REDISMODULE_CTX_FLAGS_IS_CHILD (1<<20) -/* The current client does not allow blocking, either called from - * within multi, lua, or from another module using RM_Call */ -#define REDISMODULE_CTX_FLAGS_DENY_BLOCKING (1<<21) -/* The current client uses RESP3 protocol */ -#define REDISMODULE_CTX_FLAGS_RESP3 (1<<22) -/* Redis is currently async loading database for diskless replication. */ -#define REDISMODULE_CTX_FLAGS_ASYNC_LOADING (1<<23) -/* Redis is starting. */ -#define REDISMODULE_CTX_FLAGS_SERVER_STARTUP (1<<24) - -/* 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. */ -#define _REDISMODULE_CTX_FLAGS_NEXT (1<<25) - -/* Keyspace changes notification classes. Every class is associated with a - * character for configuration purposes. - * NOTE: These have to be in sync with NOTIFY_* in server.h */ -#define REDISMODULE_NOTIFY_KEYSPACE (1<<0) /* K */ -#define REDISMODULE_NOTIFY_KEYEVENT (1<<1) /* E */ -#define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */ -#define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */ -#define REDISMODULE_NOTIFY_LIST (1<<4) /* l */ -#define REDISMODULE_NOTIFY_SET (1<<5) /* s */ -#define REDISMODULE_NOTIFY_HASH (1<<6) /* h */ -#define REDISMODULE_NOTIFY_ZSET (1<<7) /* z */ -#define REDISMODULE_NOTIFY_EXPIRED (1<<8) /* x */ -#define REDISMODULE_NOTIFY_EVICTED (1<<9) /* e */ -#define REDISMODULE_NOTIFY_STREAM (1<<10) /* t */ -#define REDISMODULE_NOTIFY_KEY_MISS (1<<11) /* m (Note: This one is excluded from REDISMODULE_NOTIFY_ALL on purpose) */ -#define REDISMODULE_NOTIFY_LOADED (1<<12) /* module only key space notification, indicate a key loaded from rdb */ -#define REDISMODULE_NOTIFY_MODULE (1<<13) /* d, module key space notification */ -#define REDISMODULE_NOTIFY_NEW (1<<14) /* n, new key notification */ - -/* 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. */ -#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) - -/* Error messages. */ -#define REDISMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value" - -#define REDISMODULE_POSITIVE_INFINITE (1.0/0.0) -#define REDISMODULE_NEGATIVE_INFINITE (-1.0/0.0) - -/* Cluster API defines. */ -#define REDISMODULE_NODE_ID_LEN 40 -#define REDISMODULE_NODE_MYSELF (1<<0) -#define REDISMODULE_NODE_MASTER (1<<1) -#define REDISMODULE_NODE_SLAVE (1<<2) -#define REDISMODULE_NODE_PFAIL (1<<3) -#define REDISMODULE_NODE_FAIL (1<<4) -#define REDISMODULE_NODE_NOFAILOVER (1<<5) - -#define REDISMODULE_CLUSTER_FLAG_NONE 0 -#define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1) -#define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2) - -#define REDISMODULE_NOT_USED(V) ((void) V) - -/* Logging level strings */ -#define REDISMODULE_LOGLEVEL_DEBUG "debug" -#define REDISMODULE_LOGLEVEL_VERBOSE "verbose" -#define REDISMODULE_LOGLEVEL_NOTICE "notice" -#define REDISMODULE_LOGLEVEL_WARNING "warning" - -/* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */ -#define REDISMODULE_AUX_BEFORE_RDB (1<<0) -#define REDISMODULE_AUX_AFTER_RDB (1<<1) - -/* RM_Yield flags */ -#define REDISMODULE_YIELD_FLAG_NONE (1<<0) -#define REDISMODULE_YIELD_FLAG_CLIENTS (1<<1) - -/* RM_BlockClientOnKeysWithFlags flags */ -#define REDISMODULE_BLOCK_UNBLOCK_DEFAULT (0) -#define REDISMODULE_BLOCK_UNBLOCK_DELETED (1<<0) - -/* This type represents a timer handle, and is returned when a timer is - * 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; - -/* CommandFilter Flags */ - -/* Do filter RedisModule_Call() commands initiated by module itself. */ -#define REDISMODULE_CMDFILTER_NOSELF (1<<0) - -/* Declare that the module can handle errors with RedisModule_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 - * 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. */ -#define REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD (1<<2) - -/* Declare that the module want to get nested key space notifications. - * If enabled, the module is responsible to break endless loop. */ -#define REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS (1<<3) - -/* 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. */ -#define _REDISMODULE_OPTIONS_FLAGS_NEXT (1<<4) - -/* Definitions for RedisModule_SetCommandInfo. */ - -typedef enum { - REDISMODULE_ARG_TYPE_STRING, - REDISMODULE_ARG_TYPE_INTEGER, - REDISMODULE_ARG_TYPE_DOUBLE, - REDISMODULE_ARG_TYPE_KEY, /* A string, but represents a keyname */ - REDISMODULE_ARG_TYPE_PATTERN, - REDISMODULE_ARG_TYPE_UNIX_TIME, - REDISMODULE_ARG_TYPE_PURE_TOKEN, - REDISMODULE_ARG_TYPE_ONEOF, /* Must have sub-arguments */ - REDISMODULE_ARG_TYPE_BLOCK /* Must have sub-arguments */ -} RedisModuleCommandArgType; - -#define REDISMODULE_CMD_ARG_NONE (0) -#define REDISMODULE_CMD_ARG_OPTIONAL (1<<0) /* The argument is optional (like GET in SET command) */ -#define REDISMODULE_CMD_ARG_MULTIPLE (1<<1) /* The argument may repeat itself (like key in DEL) */ -#define REDISMODULE_CMD_ARG_MULTIPLE_TOKEN (1<<2) /* The argument may repeat itself, and so does its token (like `GET pattern` in SORT) */ -#define _REDISMODULE_CMD_ARG_NEXT (1<<3) - -typedef enum { - REDISMODULE_KSPEC_BS_INVALID = 0, /* Must be zero. An implicitly value of - * zero is provided when the field is - * absent in a struct literal. */ - REDISMODULE_KSPEC_BS_UNKNOWN, - REDISMODULE_KSPEC_BS_INDEX, - REDISMODULE_KSPEC_BS_KEYWORD -} RedisModuleKeySpecBeginSearchType; - -typedef enum { - REDISMODULE_KSPEC_FK_OMITTED = 0, /* Used when the field is absent in a - * struct literal. Don't use this value - * explicitly. */ - REDISMODULE_KSPEC_FK_UNKNOWN, - REDISMODULE_KSPEC_FK_RANGE, - REDISMODULE_KSPEC_FK_KEYNUM -} RedisModuleKeySpecFindKeysType; - -/* Key-spec flags. For details, see the documentation of - * RedisModule_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) -#define REDISMODULE_CMD_KEY_RM (1ULL<<3) -#define REDISMODULE_CMD_KEY_ACCESS (1ULL<<4) -#define REDISMODULE_CMD_KEY_UPDATE (1ULL<<5) -#define REDISMODULE_CMD_KEY_INSERT (1ULL<<6) -#define REDISMODULE_CMD_KEY_DELETE (1ULL<<7) -#define REDISMODULE_CMD_KEY_NOT_KEY (1ULL<<8) -#define REDISMODULE_CMD_KEY_INCOMPLETE (1ULL<<9) -#define REDISMODULE_CMD_KEY_VARIABLE_FLAGS (1ULL<<10) - -/* Channel flags, for details see the documentation of - * RedisModule_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 { - const char *name; - RedisModuleCommandArgType 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. */ - const char *token; /* If type is PURE_TOKEN, this is the token. */ - const char *summary; - const char *since; - int flags; /* The REDISMODULE_CMD_ARG_* macros. */ - const char *deprecated_since; - struct RedisModuleCommandArg *subargs; - const char *display_text; -} RedisModuleCommandArg; - -typedef struct { - const char *since; - const char *changes; -} RedisModuleCommandHistoryEntry; - -typedef struct { - const char *notes; - uint64_t flags; /* REDISMODULE_CMD_KEY_* macros. */ - RedisModuleKeySpecBeginSearchType begin_search_type; - union { - struct { - /* The index from which we start the search for keys */ - int pos; - } index; - struct { - /* The keyword that indicates the beginning of key args */ - const char *keyword; - /* An index in argv from which to start searching. - * Can be negative, which means start search from the end, in reverse - * (Example: -2 means to start in reverse from the penultimate arg) */ - int startfrom; - } keyword; - } bs; - RedisModuleKeySpecFindKeysType find_keys_type; - union { - struct { - /* Index of the last key relative to the result of the begin search - * step. Can be negative, in which case it's not relative. -1 - * indicating till the last argument, -2 one before the last and so - * on. */ - int lastkey; - /* How many args should we skip after finding a key, in order to - * find the next one. */ - int keystep; - /* If lastkey is -1, we use limit to stop the search by a factor. 0 - * and 1 mean no limit. 2 means 1/2 of the remaining args, 3 means - * 1/3, and so on. */ - int limit; - } range; - struct { - /* Index of the argument containing the number of keys to come - * relative to the result of the begin search step */ - int keynumidx; - /* Index of the fist key. (Usually it's just after keynumidx, in - * which case it should be set to keynumidx + 1.) */ - int firstkey; - /* How many args should we skip after finding a key, in order to - * find the next one, relative to the result of the begin search - * step. */ - int keystep; - } keynum; - } fk; -} RedisModuleCommandKeySpec; - -typedef struct { - int version; - size_t sizeof_historyentry; - size_t sizeof_keyspec; - size_t sizeof_arg; -} RedisModuleCommandInfoVersion; - -static const RedisModuleCommandInfoVersion RedisModule_CurrentCommandInfoVersion = { - .version = 1, - .sizeof_historyentry = sizeof(RedisModuleCommandHistoryEntry), - .sizeof_keyspec = sizeof(RedisModuleCommandKeySpec), - .sizeof_arg = sizeof(RedisModuleCommandArg) -}; - -#define REDISMODULE_COMMAND_INFO_VERSION (&RedisModule_CurrentCommandInfoVersion) - -typedef struct { - /* Always set version to REDISMODULE_COMMAND_INFO_VERSION */ - const RedisModuleCommandInfoVersion *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 */ - /* 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; - -/* 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); - -/* Server events definitions. - * Those flags should not be used directly by the module, instead - * the module should use RedisModuleEvent_* variables. - * Note: This must be synced with moduleEventVersions */ -#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 -#define REDISMODULE_EVENT_PERSISTENCE 1 -#define REDISMODULE_EVENT_FLUSHDB 2 -#define REDISMODULE_EVENT_LOADING 3 -#define REDISMODULE_EVENT_CLIENT_CHANGE 4 -#define REDISMODULE_EVENT_SHUTDOWN 5 -#define REDISMODULE_EVENT_REPLICA_CHANGE 6 -#define REDISMODULE_EVENT_MASTER_LINK_CHANGE 7 -#define REDISMODULE_EVENT_CRON_LOOP 8 -#define REDISMODULE_EVENT_MODULE_CHANGE 9 -#define REDISMODULE_EVENT_LOADING_PROGRESS 10 -#define REDISMODULE_EVENT_SWAPDB 11 -#define REDISMODULE_EVENT_REPL_BACKUP 12 /* Deprecated since Redis 7.0, not used anymore. */ -#define REDISMODULE_EVENT_FORK_CHILD 13 -#define REDISMODULE_EVENT_REPL_ASYNC_LOAD 14 -#define REDISMODULE_EVENT_EVENTLOOP 15 -#define REDISMODULE_EVENT_CONFIG 16 -#define REDISMODULE_EVENT_KEY 17 -#define _REDISMODULE_EVENT_NEXT 18 /* Next event flag, should be updated if a new event added. */ - -typedef struct RedisModuleEvent { - uint64_t id; /* REDISMODULE_EVENT_... defines. */ - uint64_t dataver; /* Version of the structure we pass as 'data'. */ -} RedisModuleEvent; - -struct RedisModuleCtx; -struct RedisModuleDefragCtx; -typedef void (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent 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 - * structures should be: - * RedisModuleEvent_FlushDB = { - * REDISMODULE_EVENT_FLUSHDB, - * 1 - * }, - * RedisModuleEvent_FlushDBV2 = { - * REDISMODULE_EVENT_FLUSHDB, - * 2 - * } - * and NOT: - * RedisModuleEvent_FlushDBV1 = { - * REDISMODULE_EVENT_FLUSHDB, - * 1 - * }, - * RedisModuleEvent_FlushDB = { - * REDISMODULE_EVENT_FLUSHDB, - * 2 - * } - * The reason for that is forward-compatibility: We want that module that - * compiled with a new redismodule.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 = { - REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - 1 - }, - RedisModuleEvent_Persistence = { - REDISMODULE_EVENT_PERSISTENCE, - 1 - }, - RedisModuleEvent_FlushDB = { - REDISMODULE_EVENT_FLUSHDB, - 1 - }, - RedisModuleEvent_Loading = { - REDISMODULE_EVENT_LOADING, - 1 - }, - RedisModuleEvent_ClientChange = { - REDISMODULE_EVENT_CLIENT_CHANGE, - 1 - }, - RedisModuleEvent_Shutdown = { - REDISMODULE_EVENT_SHUTDOWN, - 1 - }, - RedisModuleEvent_ReplicaChange = { - REDISMODULE_EVENT_REPLICA_CHANGE, - 1 - }, - RedisModuleEvent_CronLoop = { - REDISMODULE_EVENT_CRON_LOOP, - 1 - }, - RedisModuleEvent_MasterLinkChange = { - REDISMODULE_EVENT_MASTER_LINK_CHANGE, - 1 - }, - RedisModuleEvent_ModuleChange = { - REDISMODULE_EVENT_MODULE_CHANGE, - 1 - }, - RedisModuleEvent_LoadingProgress = { - REDISMODULE_EVENT_LOADING_PROGRESS, - 1 - }, - RedisModuleEvent_SwapDB = { - REDISMODULE_EVENT_SWAPDB, - 1 - }, - /* Deprecated since Redis 7.0, not used anymore. */ - __attribute__ ((deprecated)) - RedisModuleEvent_ReplBackup = { - REDISMODULE_EVENT_REPL_BACKUP, - 1 - }, - RedisModuleEvent_ReplAsyncLoad = { - REDISMODULE_EVENT_REPL_ASYNC_LOAD, - 1 - }, - RedisModuleEvent_ForkChild = { - REDISMODULE_EVENT_FORK_CHILD, - 1 - }, - RedisModuleEvent_EventLoop = { - REDISMODULE_EVENT_EVENTLOOP, - 1 - }, - RedisModuleEvent_Config = { - REDISMODULE_EVENT_CONFIG, - 1 - }, - RedisModuleEvent_Key = { - REDISMODULE_EVENT_KEY, - 1 - }; - -/* Those are values that are used for the 'subevent' callback argument. */ -#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START 0 -#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START 1 -#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START 2 -#define REDISMODULE_SUBEVENT_PERSISTENCE_ENDED 3 -#define REDISMODULE_SUBEVENT_PERSISTENCE_FAILED 4 -#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START 5 -#define _REDISMODULE_SUBEVENT_PERSISTENCE_NEXT 6 - -#define REDISMODULE_SUBEVENT_LOADING_RDB_START 0 -#define REDISMODULE_SUBEVENT_LOADING_AOF_START 1 -#define REDISMODULE_SUBEVENT_LOADING_REPL_START 2 -#define REDISMODULE_SUBEVENT_LOADING_ENDED 3 -#define REDISMODULE_SUBEVENT_LOADING_FAILED 4 -#define _REDISMODULE_SUBEVENT_LOADING_NEXT 5 - -#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0 -#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1 -#define _REDISMODULE_SUBEVENT_CLIENT_CHANGE_NEXT 2 - -#define REDISMODULE_SUBEVENT_MASTER_LINK_UP 0 -#define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN 1 -#define _REDISMODULE_SUBEVENT_MASTER_NEXT 2 - -#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE 0 -#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE 1 -#define _REDISMODULE_SUBEVENT_REPLICA_CHANGE_NEXT 2 - -#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER 0 -#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA 1 -#define _REDISMODULE_EVENT_REPLROLECHANGED_NEXT 2 - -#define REDISMODULE_SUBEVENT_FLUSHDB_START 0 -#define REDISMODULE_SUBEVENT_FLUSHDB_END 1 -#define _REDISMODULE_SUBEVENT_FLUSHDB_NEXT 2 - -#define REDISMODULE_SUBEVENT_MODULE_LOADED 0 -#define REDISMODULE_SUBEVENT_MODULE_UNLOADED 1 -#define _REDISMODULE_SUBEVENT_MODULE_NEXT 2 - -#define REDISMODULE_SUBEVENT_CONFIG_CHANGE 0 -#define _REDISMODULE_SUBEVENT_CONFIG_NEXT 1 - -#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB 0 -#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF 1 -#define _REDISMODULE_SUBEVENT_LOADING_PROGRESS_NEXT 2 - -/* Replication Backup events are deprecated since Redis 7.0 and are never fired. */ -#define REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE 0 -#define REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE 1 -#define REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD 2 -#define _REDISMODULE_SUBEVENT_REPL_BACKUP_NEXT 3 - -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED 0 -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED 1 -#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED 2 -#define _REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT 3 - -#define REDISMODULE_SUBEVENT_FORK_CHILD_BORN 0 -#define REDISMODULE_SUBEVENT_FORK_CHILD_DIED 1 -#define _REDISMODULE_SUBEVENT_FORK_CHILD_NEXT 2 - -#define REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP 0 -#define REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP 1 -#define _REDISMODULE_SUBEVENT_EVENTLOOP_NEXT 2 - -#define REDISMODULE_SUBEVENT_KEY_DELETED 0 -#define REDISMODULE_SUBEVENT_KEY_EXPIRED 1 -#define REDISMODULE_SUBEVENT_KEY_EVICTED 2 -#define REDISMODULE_SUBEVENT_KEY_OVERWRITTEN 3 -#define _REDISMODULE_SUBEVENT_KEY_NEXT 4 - -#define _REDISMODULE_SUBEVENT_SHUTDOWN_NEXT 0 -#define _REDISMODULE_SUBEVENT_CRON_LOOP_NEXT 0 -#define _REDISMODULE_SUBEVENT_SWAPDB_NEXT 0 - -/* RedisModuleClientInfo flags. */ -#define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0) -#define REDISMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1) -#define REDISMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2) -#define REDISMODULE_CLIENTINFO_FLAG_TRACKING (1<<3) -#define REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET (1<<4) -#define REDISMODULE_CLIENTINFO_FLAG_MULTI (1<<5) - -/* 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(). + * Important Note: + * This file represents a snapshot of the Redis module interfaces as they existed + * in Redis 7.2.4. Compatibility with future Redis versions is not guaranteed. + * + * Usage: + * Include this header in Redis modules that originally depend on the older + * REDISMODULE_* definitions. This file should be included instead of + * directly including valkeymodule.h to ensure the legacy code recognizes + * the new Valkey module interfaces. * - * 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, - * for the APIs to fill the structure. In that case, the structure 'version' - * field is initialized before passing it to the core, so that the core is - * able to cast the pointer to the appropriate structure version. In this - * way we obtain ABI compatibility. + * Example: + * #include "redismodule.h" * - * Here we'll list all the structure versions in case they evolve over time, - * however using a define, we'll make sure to use the last version as the - * public name for the module to use. */ - -#define REDISMODULE_CLIENTINFO_VERSION 1 -typedef struct RedisModuleClientInfo { - 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; - -#define RedisModuleClientInfo RedisModuleClientInfoV1 - -#define REDISMODULE_CLIENTINFO_INITIALIZER_V1 { .version = 1 } - -#define REDISMODULE_REPLICATIONINFO_VERSION 1 -typedef struct RedisModuleReplicationInfo { - uint64_t version; /* Not used since this structure is never passed - from the module to the core right now. Here - for future compatibility. */ - int master; /* true if master, false if replica */ - char *masterhost; /* master instance hostname for NOW_REPLICA */ - int masterport; /* master instance port for NOW_REPLICA */ - char *replid1; /* Main replication ID */ - char *replid2; /* Secondary replication ID */ - uint64_t repl1_offset; /* Main replication offset */ - uint64_t repl2_offset; /* Offset of replid2 validity */ -} RedisModuleReplicationInfoV1; - -#define RedisModuleReplicationInfo RedisModuleReplicationInfoV1 - -#define REDISMODULE_FLUSHINFO_VERSION 1 -typedef struct RedisModuleFlushInfo { - 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; - -#define RedisModuleFlushInfo RedisModuleFlushInfoV1 - -#define REDISMODULE_MODULE_CHANGE_VERSION 1 -typedef struct RedisModuleModuleChange { - 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; - -#define RedisModuleModuleChange RedisModuleModuleChangeV1 - -#define REDISMODULE_CONFIGCHANGE_VERSION 1 -typedef struct RedisModuleConfigChange { - 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; - -#define RedisModuleConfigChange RedisModuleConfigChangeV1 - -#define REDISMODULE_CRON_LOOP_VERSION 1 -typedef struct RedisModuleCronLoopInfo { - 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; - -#define RedisModuleCronLoop RedisModuleCronLoopV1 - -#define REDISMODULE_LOADING_PROGRESS_VERSION 1 -typedef struct RedisModuleLoadingProgressInfo { - 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; - -#define RedisModuleLoadingProgress RedisModuleLoadingProgressV1 - -#define REDISMODULE_SWAPDBINFO_VERSION 1 -typedef struct RedisModuleSwapDbInfo { - 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; - -#define RedisModuleSwapDbInfo RedisModuleSwapDbInfoV1 - -#define REDISMODULE_KEYINFO_VERSION 1 -typedef struct RedisModuleKeyInfo { - 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; - -#define RedisModuleKeyInfo RedisModuleKeyInfoV1 - -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; - -/* 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; - -/* 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); - -/* ------------------------- End of common defines ------------------------ */ - -/* ----------- The rest of the defines are only for modules ----------------- */ -#if !defined REDISMODULE_CORE || defined REDISMODULE_CORE_MODULE -/* Things defined for modules and core-modules. */ - -/* Macro definitions specific to individual compilers */ -#ifndef REDISMODULE_ATTR_UNUSED -# ifdef __GNUC__ -# define REDISMODULE_ATTR_UNUSED __attribute__((unused)) -# else -# define REDISMODULE_ATTR_UNUSED -# endif -#endif - -#ifndef REDISMODULE_ATTR_PRINTF -# ifdef __GNUC__ -# define REDISMODULE_ATTR_PRINTF(idx,cnt) __attribute__((format(printf,idx,cnt))) -# else -# define REDISMODULE_ATTR_PRINTF(idx,cnt) -# endif -#endif - -#ifndef REDISMODULE_ATTR_COMMON -# if defined(__GNUC__) && !(defined(__clang__) && defined(__cplusplus)) -# define REDISMODULE_ATTR_COMMON __attribute__((__common__)) -# else -# define REDISMODULE_ATTR_COMMON -# endif -#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 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 struct RedisModuleTypeMethods { - 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; - 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; - -#define REDISMODULE_GET_API(name) \ - RedisModule_GetApi("RedisModule_" #name, ((void **)&RedisModule_ ## name)) - -/* Default API declaration prefix (not 'extern' for backwards compatibility) */ -#ifndef REDISMODULE_API -#define REDISMODULE_API -#endif - -/* Default API declaration suffix (compiler attributes) */ -#ifndef REDISMODULE_ATTR -#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; - -#define RedisModule_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) { - void *getapifuncptr = ((void**)ctx)[0]; - RedisModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; - REDISMODULE_GET_API(Alloc); - REDISMODULE_GET_API(TryAlloc); - REDISMODULE_GET_API(Calloc); - REDISMODULE_GET_API(TryCalloc); - REDISMODULE_GET_API(Free); - REDISMODULE_GET_API(Realloc); - REDISMODULE_GET_API(TryRealloc); - REDISMODULE_GET_API(Strdup); - REDISMODULE_GET_API(CreateCommand); - REDISMODULE_GET_API(GetCommand); - REDISMODULE_GET_API(CreateSubcommand); - REDISMODULE_GET_API(SetCommandInfo); - REDISMODULE_GET_API(SetCommandACLCategories); - REDISMODULE_GET_API(AddACLCategory); - REDISMODULE_GET_API(SetModuleAttribs); - REDISMODULE_GET_API(IsModuleNameBusy); - REDISMODULE_GET_API(WrongArity); - REDISMODULE_GET_API(ReplyWithLongLong); - REDISMODULE_GET_API(ReplyWithError); - REDISMODULE_GET_API(ReplyWithErrorFormat); - REDISMODULE_GET_API(ReplyWithSimpleString); - REDISMODULE_GET_API(ReplyWithArray); - REDISMODULE_GET_API(ReplyWithMap); - REDISMODULE_GET_API(ReplyWithSet); - REDISMODULE_GET_API(ReplyWithAttribute); - REDISMODULE_GET_API(ReplyWithNullArray); - REDISMODULE_GET_API(ReplyWithEmptyArray); - REDISMODULE_GET_API(ReplySetArrayLength); - REDISMODULE_GET_API(ReplySetMapLength); - REDISMODULE_GET_API(ReplySetSetLength); - REDISMODULE_GET_API(ReplySetAttributeLength); - REDISMODULE_GET_API(ReplySetPushLength); - REDISMODULE_GET_API(ReplyWithStringBuffer); - REDISMODULE_GET_API(ReplyWithCString); - REDISMODULE_GET_API(ReplyWithString); - REDISMODULE_GET_API(ReplyWithEmptyString); - REDISMODULE_GET_API(ReplyWithVerbatimString); - REDISMODULE_GET_API(ReplyWithVerbatimStringType); - REDISMODULE_GET_API(ReplyWithNull); - REDISMODULE_GET_API(ReplyWithBool); - REDISMODULE_GET_API(ReplyWithCallReply); - REDISMODULE_GET_API(ReplyWithDouble); - REDISMODULE_GET_API(ReplyWithBigNumber); - REDISMODULE_GET_API(ReplyWithLongDouble); - REDISMODULE_GET_API(GetSelectedDb); - REDISMODULE_GET_API(SelectDb); - REDISMODULE_GET_API(KeyExists); - REDISMODULE_GET_API(OpenKey); - REDISMODULE_GET_API(GetOpenKeyModesAll); - REDISMODULE_GET_API(CloseKey); - REDISMODULE_GET_API(KeyType); - REDISMODULE_GET_API(ValueLength); - REDISMODULE_GET_API(ListPush); - REDISMODULE_GET_API(ListPop); - REDISMODULE_GET_API(ListGet); - REDISMODULE_GET_API(ListSet); - REDISMODULE_GET_API(ListInsert); - REDISMODULE_GET_API(ListDelete); - REDISMODULE_GET_API(StringToLongLong); - REDISMODULE_GET_API(StringToULongLong); - REDISMODULE_GET_API(StringToDouble); - REDISMODULE_GET_API(StringToLongDouble); - REDISMODULE_GET_API(StringToStreamID); - REDISMODULE_GET_API(Call); - REDISMODULE_GET_API(CallReplyProto); - REDISMODULE_GET_API(FreeCallReply); - REDISMODULE_GET_API(CallReplyInteger); - REDISMODULE_GET_API(CallReplyDouble); - REDISMODULE_GET_API(CallReplyBool); - REDISMODULE_GET_API(CallReplyBigNumber); - REDISMODULE_GET_API(CallReplyVerbatim); - REDISMODULE_GET_API(CallReplySetElement); - REDISMODULE_GET_API(CallReplyMapElement); - REDISMODULE_GET_API(CallReplyAttributeElement); - REDISMODULE_GET_API(CallReplyPromiseSetUnblockHandler); - REDISMODULE_GET_API(CallReplyPromiseAbort); - REDISMODULE_GET_API(CallReplyAttribute); - REDISMODULE_GET_API(CallReplyType); - REDISMODULE_GET_API(CallReplyLength); - REDISMODULE_GET_API(CallReplyArrayElement); - REDISMODULE_GET_API(CallReplyStringPtr); - REDISMODULE_GET_API(CreateStringFromCallReply); - REDISMODULE_GET_API(CreateString); - REDISMODULE_GET_API(CreateStringFromLongLong); - REDISMODULE_GET_API(CreateStringFromULongLong); - REDISMODULE_GET_API(CreateStringFromDouble); - REDISMODULE_GET_API(CreateStringFromLongDouble); - REDISMODULE_GET_API(CreateStringFromString); - REDISMODULE_GET_API(CreateStringFromStreamID); - REDISMODULE_GET_API(CreateStringPrintf); - REDISMODULE_GET_API(FreeString); - REDISMODULE_GET_API(StringPtrLen); - REDISMODULE_GET_API(AutoMemory); - REDISMODULE_GET_API(Replicate); - REDISMODULE_GET_API(ReplicateVerbatim); - REDISMODULE_GET_API(DeleteKey); - REDISMODULE_GET_API(UnlinkKey); - REDISMODULE_GET_API(StringSet); - REDISMODULE_GET_API(StringDMA); - REDISMODULE_GET_API(StringTruncate); - REDISMODULE_GET_API(GetExpire); - REDISMODULE_GET_API(SetExpire); - REDISMODULE_GET_API(GetAbsExpire); - REDISMODULE_GET_API(SetAbsExpire); - REDISMODULE_GET_API(ResetDataset); - REDISMODULE_GET_API(DbSize); - REDISMODULE_GET_API(RandomKey); - REDISMODULE_GET_API(ZsetAdd); - REDISMODULE_GET_API(ZsetIncrby); - REDISMODULE_GET_API(ZsetScore); - REDISMODULE_GET_API(ZsetRem); - REDISMODULE_GET_API(ZsetRangeStop); - REDISMODULE_GET_API(ZsetFirstInScoreRange); - REDISMODULE_GET_API(ZsetLastInScoreRange); - REDISMODULE_GET_API(ZsetFirstInLexRange); - REDISMODULE_GET_API(ZsetLastInLexRange); - REDISMODULE_GET_API(ZsetRangeCurrentElement); - REDISMODULE_GET_API(ZsetRangeNext); - REDISMODULE_GET_API(ZsetRangePrev); - REDISMODULE_GET_API(ZsetRangeEndReached); - REDISMODULE_GET_API(HashSet); - REDISMODULE_GET_API(HashGet); - REDISMODULE_GET_API(StreamAdd); - REDISMODULE_GET_API(StreamDelete); - REDISMODULE_GET_API(StreamIteratorStart); - REDISMODULE_GET_API(StreamIteratorStop); - REDISMODULE_GET_API(StreamIteratorNextID); - REDISMODULE_GET_API(StreamIteratorNextField); - REDISMODULE_GET_API(StreamIteratorDelete); - REDISMODULE_GET_API(StreamTrimByLength); - REDISMODULE_GET_API(StreamTrimByID); - REDISMODULE_GET_API(IsKeysPositionRequest); - REDISMODULE_GET_API(KeyAtPos); - REDISMODULE_GET_API(KeyAtPosWithFlags); - REDISMODULE_GET_API(IsChannelsPositionRequest); - REDISMODULE_GET_API(ChannelAtPosWithFlags); - REDISMODULE_GET_API(GetClientId); - REDISMODULE_GET_API(GetClientUserNameById); - REDISMODULE_GET_API(GetContextFlags); - REDISMODULE_GET_API(AvoidReplicaTraffic); - REDISMODULE_GET_API(PoolAlloc); - REDISMODULE_GET_API(CreateDataType); - REDISMODULE_GET_API(ModuleTypeSetValue); - REDISMODULE_GET_API(ModuleTypeReplaceValue); - REDISMODULE_GET_API(ModuleTypeGetType); - REDISMODULE_GET_API(ModuleTypeGetValue); - REDISMODULE_GET_API(IsIOError); - REDISMODULE_GET_API(SetModuleOptions); - REDISMODULE_GET_API(SignalModifiedKey); - REDISMODULE_GET_API(SaveUnsigned); - REDISMODULE_GET_API(LoadUnsigned); - REDISMODULE_GET_API(SaveSigned); - REDISMODULE_GET_API(LoadSigned); - REDISMODULE_GET_API(SaveString); - REDISMODULE_GET_API(SaveStringBuffer); - REDISMODULE_GET_API(LoadString); - REDISMODULE_GET_API(LoadStringBuffer); - REDISMODULE_GET_API(SaveDouble); - REDISMODULE_GET_API(LoadDouble); - REDISMODULE_GET_API(SaveFloat); - REDISMODULE_GET_API(LoadFloat); - REDISMODULE_GET_API(SaveLongDouble); - REDISMODULE_GET_API(LoadLongDouble); - REDISMODULE_GET_API(SaveDataTypeToString); - REDISMODULE_GET_API(LoadDataTypeFromString); - REDISMODULE_GET_API(LoadDataTypeFromStringEncver); - REDISMODULE_GET_API(EmitAOF); - REDISMODULE_GET_API(Log); - REDISMODULE_GET_API(LogIOError); - REDISMODULE_GET_API(_Assert); - REDISMODULE_GET_API(LatencyAddSample); - REDISMODULE_GET_API(StringAppendBuffer); - REDISMODULE_GET_API(TrimStringAllocation); - REDISMODULE_GET_API(RetainString); - REDISMODULE_GET_API(HoldString); - REDISMODULE_GET_API(StringCompare); - REDISMODULE_GET_API(GetContextFromIO); - REDISMODULE_GET_API(GetKeyNameFromIO); - REDISMODULE_GET_API(GetKeyNameFromModuleKey); - REDISMODULE_GET_API(GetDbIdFromModuleKey); - REDISMODULE_GET_API(GetDbIdFromIO); - REDISMODULE_GET_API(GetKeyNameFromOptCtx); - REDISMODULE_GET_API(GetToKeyNameFromOptCtx); - REDISMODULE_GET_API(GetDbIdFromOptCtx); - REDISMODULE_GET_API(GetToDbIdFromOptCtx); - REDISMODULE_GET_API(Milliseconds); - REDISMODULE_GET_API(MonotonicMicroseconds); - REDISMODULE_GET_API(Microseconds); - REDISMODULE_GET_API(CachedMicroseconds); - REDISMODULE_GET_API(DigestAddStringBuffer); - REDISMODULE_GET_API(DigestAddLongLong); - REDISMODULE_GET_API(DigestEndSequence); - REDISMODULE_GET_API(GetKeyNameFromDigest); - REDISMODULE_GET_API(GetDbIdFromDigest); - REDISMODULE_GET_API(CreateDict); - REDISMODULE_GET_API(FreeDict); - REDISMODULE_GET_API(DictSize); - REDISMODULE_GET_API(DictSetC); - REDISMODULE_GET_API(DictReplaceC); - REDISMODULE_GET_API(DictSet); - REDISMODULE_GET_API(DictReplace); - REDISMODULE_GET_API(DictGetC); - REDISMODULE_GET_API(DictGet); - REDISMODULE_GET_API(DictDelC); - REDISMODULE_GET_API(DictDel); - REDISMODULE_GET_API(DictIteratorStartC); - REDISMODULE_GET_API(DictIteratorStart); - REDISMODULE_GET_API(DictIteratorStop); - REDISMODULE_GET_API(DictIteratorReseekC); - REDISMODULE_GET_API(DictIteratorReseek); - REDISMODULE_GET_API(DictNextC); - REDISMODULE_GET_API(DictPrevC); - REDISMODULE_GET_API(DictNext); - REDISMODULE_GET_API(DictPrev); - REDISMODULE_GET_API(DictCompare); - REDISMODULE_GET_API(DictCompareC); - REDISMODULE_GET_API(RegisterInfoFunc); - REDISMODULE_GET_API(RegisterAuthCallback); - REDISMODULE_GET_API(InfoAddSection); - REDISMODULE_GET_API(InfoBeginDictField); - REDISMODULE_GET_API(InfoEndDictField); - REDISMODULE_GET_API(InfoAddFieldString); - REDISMODULE_GET_API(InfoAddFieldCString); - REDISMODULE_GET_API(InfoAddFieldDouble); - REDISMODULE_GET_API(InfoAddFieldLongLong); - REDISMODULE_GET_API(InfoAddFieldULongLong); - REDISMODULE_GET_API(GetServerInfo); - REDISMODULE_GET_API(FreeServerInfo); - REDISMODULE_GET_API(ServerInfoGetField); - REDISMODULE_GET_API(ServerInfoGetFieldC); - REDISMODULE_GET_API(ServerInfoGetFieldSigned); - REDISMODULE_GET_API(ServerInfoGetFieldUnsigned); - REDISMODULE_GET_API(ServerInfoGetFieldDouble); - REDISMODULE_GET_API(GetClientInfoById); - REDISMODULE_GET_API(GetClientNameById); - REDISMODULE_GET_API(SetClientNameById); - REDISMODULE_GET_API(PublishMessage); - REDISMODULE_GET_API(PublishMessageShard); - REDISMODULE_GET_API(SubscribeToServerEvent); - REDISMODULE_GET_API(SetLRU); - REDISMODULE_GET_API(GetLRU); - REDISMODULE_GET_API(SetLFU); - REDISMODULE_GET_API(GetLFU); - REDISMODULE_GET_API(BlockClientOnKeys); - REDISMODULE_GET_API(BlockClientOnKeysWithFlags); - REDISMODULE_GET_API(SignalKeyAsReady); - REDISMODULE_GET_API(GetBlockedClientReadyKey); - REDISMODULE_GET_API(ScanCursorCreate); - REDISMODULE_GET_API(ScanCursorRestart); - REDISMODULE_GET_API(ScanCursorDestroy); - REDISMODULE_GET_API(Scan); - REDISMODULE_GET_API(ScanKey); - REDISMODULE_GET_API(GetContextFlagsAll); - REDISMODULE_GET_API(GetModuleOptionsAll); - REDISMODULE_GET_API(GetKeyspaceNotificationFlagsAll); - REDISMODULE_GET_API(IsSubEventSupported); - REDISMODULE_GET_API(GetServerVersion); - REDISMODULE_GET_API(GetTypeMethodVersion); - REDISMODULE_GET_API(Yield); - REDISMODULE_GET_API(GetThreadSafeContext); - REDISMODULE_GET_API(GetDetachedThreadSafeContext); - REDISMODULE_GET_API(FreeThreadSafeContext); - REDISMODULE_GET_API(ThreadSafeContextLock); - REDISMODULE_GET_API(ThreadSafeContextTryLock); - REDISMODULE_GET_API(ThreadSafeContextUnlock); - REDISMODULE_GET_API(BlockClient); - REDISMODULE_GET_API(BlockClientGetPrivateData); - REDISMODULE_GET_API(BlockClientSetPrivateData); - REDISMODULE_GET_API(BlockClientOnAuth); - REDISMODULE_GET_API(UnblockClient); - REDISMODULE_GET_API(IsBlockedReplyRequest); - REDISMODULE_GET_API(IsBlockedTimeoutRequest); - REDISMODULE_GET_API(GetBlockedClientPrivateData); - REDISMODULE_GET_API(GetBlockedClientHandle); - REDISMODULE_GET_API(AbortBlock); - REDISMODULE_GET_API(BlockedClientMeasureTimeStart); - REDISMODULE_GET_API(BlockedClientMeasureTimeEnd); - REDISMODULE_GET_API(SetDisconnectCallback); - REDISMODULE_GET_API(SubscribeToKeyspaceEvents); - REDISMODULE_GET_API(AddPostNotificationJob); - REDISMODULE_GET_API(NotifyKeyspaceEvent); - REDISMODULE_GET_API(GetNotifyKeyspaceEvents); - REDISMODULE_GET_API(BlockedClientDisconnected); - REDISMODULE_GET_API(RegisterClusterMessageReceiver); - REDISMODULE_GET_API(SendClusterMessage); - REDISMODULE_GET_API(GetClusterNodeInfo); - REDISMODULE_GET_API(GetClusterNodesList); - REDISMODULE_GET_API(FreeClusterNodesList); - REDISMODULE_GET_API(CreateTimer); - REDISMODULE_GET_API(StopTimer); - REDISMODULE_GET_API(GetTimerInfo); - REDISMODULE_GET_API(GetMyClusterID); - REDISMODULE_GET_API(GetClusterSize); - REDISMODULE_GET_API(GetRandomBytes); - REDISMODULE_GET_API(GetRandomHexChars); - REDISMODULE_GET_API(SetClusterFlags); - REDISMODULE_GET_API(ClusterKeySlot); - REDISMODULE_GET_API(ClusterCanonicalKeyNameInSlot); - REDISMODULE_GET_API(ExportSharedAPI); - REDISMODULE_GET_API(GetSharedAPI); - REDISMODULE_GET_API(RegisterCommandFilter); - REDISMODULE_GET_API(UnregisterCommandFilter); - REDISMODULE_GET_API(CommandFilterArgsCount); - REDISMODULE_GET_API(CommandFilterArgGet); - REDISMODULE_GET_API(CommandFilterArgInsert); - REDISMODULE_GET_API(CommandFilterArgReplace); - REDISMODULE_GET_API(CommandFilterArgDelete); - REDISMODULE_GET_API(CommandFilterGetClientId); - REDISMODULE_GET_API(Fork); - REDISMODULE_GET_API(SendChildHeartbeat); - REDISMODULE_GET_API(ExitFromChild); - REDISMODULE_GET_API(KillForkChild); - REDISMODULE_GET_API(GetUsedMemoryRatio); - REDISMODULE_GET_API(MallocSize); - REDISMODULE_GET_API(MallocUsableSize); - REDISMODULE_GET_API(MallocSizeString); - REDISMODULE_GET_API(MallocSizeDict); - REDISMODULE_GET_API(CreateModuleUser); - REDISMODULE_GET_API(FreeModuleUser); - REDISMODULE_GET_API(SetContextUser); - REDISMODULE_GET_API(SetModuleUserACL); - REDISMODULE_GET_API(SetModuleUserACLString); - REDISMODULE_GET_API(GetModuleUserACLString); - REDISMODULE_GET_API(GetCurrentUserName); - REDISMODULE_GET_API(GetModuleUserFromUserName); - REDISMODULE_GET_API(ACLCheckCommandPermissions); - REDISMODULE_GET_API(ACLCheckKeyPermissions); - REDISMODULE_GET_API(ACLCheckChannelPermissions); - REDISMODULE_GET_API(ACLAddLogEntry); - REDISMODULE_GET_API(ACLAddLogEntryByUserName); - REDISMODULE_GET_API(DeauthenticateAndCloseClient); - REDISMODULE_GET_API(AuthenticateClientWithACLUser); - REDISMODULE_GET_API(AuthenticateClientWithUser); - REDISMODULE_GET_API(RedactClientCommandArgument); - REDISMODULE_GET_API(GetClientCertificate); - REDISMODULE_GET_API(GetCommandKeys); - REDISMODULE_GET_API(GetCommandKeysWithFlags); - REDISMODULE_GET_API(GetCurrentCommandName); - REDISMODULE_GET_API(RegisterDefragFunc); - REDISMODULE_GET_API(DefragAlloc); - REDISMODULE_GET_API(DefragRedisModuleString); - REDISMODULE_GET_API(DefragShouldStop); - REDISMODULE_GET_API(DefragCursorSet); - REDISMODULE_GET_API(DefragCursorGet); - REDISMODULE_GET_API(GetKeyNameFromDefragCtx); - REDISMODULE_GET_API(GetDbIdFromDefragCtx); - REDISMODULE_GET_API(EventLoopAdd); - REDISMODULE_GET_API(EventLoopDel); - REDISMODULE_GET_API(EventLoopAddOneShot); - REDISMODULE_GET_API(RegisterBoolConfig); - REDISMODULE_GET_API(RegisterNumericConfig); - REDISMODULE_GET_API(RegisterStringConfig); - REDISMODULE_GET_API(RegisterEnumConfig); - REDISMODULE_GET_API(LoadConfigs); - REDISMODULE_GET_API(RdbStreamCreateFromFile); - REDISMODULE_GET_API(RdbStreamFree); - REDISMODULE_GET_API(RdbLoad); - REDISMODULE_GET_API(RdbSave); - - if (RedisModule_IsModuleNameBusy && RedisModule_IsModuleNameBusy(name)) return REDISMODULE_ERR; - RedisModule_SetModuleAttribs(ctx,name,ver,apiver); - return REDISMODULE_OK; -} - -#define RedisModule_Assert(_e) ((_e)?(void)0 : (RedisModule__Assert(#_e,__FILE__,__LINE__),exit(1))) - -#define RMAPI_FUNC_SUPPORTED(func) (func != NULL) + * The above directive will pull in the VALKEYMODULE_* definitions while + * ensuring that any reference to REDISMODULE_* in the module's source + * will resolve to the appropriate VALKEYMODULE_* counterpart. + */ -#endif /* REDISMODULE_CORE */ -#endif /* REDISMODULE_H */ +#include "valkeymodule.h" +#define REDISMODULE_H VALKEYMODULE_H +#define REDISMODULE_OK VALKEYMODULE_OK +#define REDISMODULE_ERR VALKEYMODULE_ERR +#define REDISMODULE_AUTH_HANDLED VALKEYMODULE_AUTH_HANDLED +#define REDISMODULE_AUTH_NOT_HANDLED VALKEYMODULE_AUTH_NOT_HANDLED +#define REDISMODULE_APIVER_1 VALKEYMODULE_APIVER_1 +#define REDISMODULE_TYPE_METHOD_VERSION VALKEYMODULE_TYPE_METHOD_VERSION +#define REDISMODULE_READ VALKEYMODULE_READ +#define REDISMODULE_WRITE VALKEYMODULE_WRITE +#define REDISMODULE_OPEN_KEY_NOTOUCH VALKEYMODULE_OPEN_KEY_NOTOUCH +#define REDISMODULE_OPEN_KEY_NONOTIFY VALKEYMODULE_OPEN_KEY_NONOTIFY +#define REDISMODULE_OPEN_KEY_NOSTATS VALKEYMODULE_OPEN_KEY_NOSTATS +#define REDISMODULE_OPEN_KEY_NOEXPIRE VALKEYMODULE_OPEN_KEY_NOEXPIRE +#define REDISMODULE_OPEN_KEY_NOEFFECTS VALKEYMODULE_OPEN_KEY_NOEFFECTS +#define REDISMODULE_LIST_HEAD VALKEYMODULE_LIST_HEAD +#define REDISMODULE_LIST_TAIL VALKEYMODULE_LIST_TAIL +#define REDISMODULE_KEYTYPE_EMPTY VALKEYMODULE_KEYTYPE_EMPTY +#define REDISMODULE_KEYTYPE_STRING VALKEYMODULE_KEYTYPE_STRING +#define REDISMODULE_KEYTYPE_LIST VALKEYMODULE_KEYTYPE_LIST +#define REDISMODULE_KEYTYPE_HASH VALKEYMODULE_KEYTYPE_HASH +#define REDISMODULE_KEYTYPE_SET VALKEYMODULE_KEYTYPE_SET +#define REDISMODULE_KEYTYPE_ZSET VALKEYMODULE_KEYTYPE_ZSET +#define REDISMODULE_KEYTYPE_MODULE VALKEYMODULE_KEYTYPE_MODULE +#define REDISMODULE_KEYTYPE_STREAM VALKEYMODULE_KEYTYPE_STREAM +#define REDISMODULE_REPLY_UNKNOWN VALKEYMODULE_REPLY_UNKNOWN +#define REDISMODULE_REPLY_STRING VALKEYMODULE_REPLY_STRING +#define REDISMODULE_REPLY_ERROR VALKEYMODULE_REPLY_ERROR +#define REDISMODULE_REPLY_INTEGER VALKEYMODULE_REPLY_INTEGER +#define REDISMODULE_REPLY_ARRAY VALKEYMODULE_REPLY_ARRAY +#define REDISMODULE_REPLY_NULL VALKEYMODULE_REPLY_NULL +#define REDISMODULE_REPLY_MAP VALKEYMODULE_REPLY_MAP +#define REDISMODULE_REPLY_SET VALKEYMODULE_REPLY_SET +#define REDISMODULE_REPLY_BOOL VALKEYMODULE_REPLY_BOOL +#define REDISMODULE_REPLY_DOUBLE VALKEYMODULE_REPLY_DOUBLE +#define REDISMODULE_REPLY_BIG_NUMBER VALKEYMODULE_REPLY_BIG_NUMBER +#define REDISMODULE_REPLY_VERBATIM_STRING VALKEYMODULE_REPLY_VERBATIM_STRING +#define REDISMODULE_REPLY_ATTRIBUTE VALKEYMODULE_REPLY_ATTRIBUTE +#define REDISMODULE_REPLY_PROMISE VALKEYMODULE_REPLY_PROMISE +#define REDISMODULE_POSTPONED_ARRAY_LEN VALKEYMODULE_POSTPONED_ARRAY_LEN +#define REDISMODULE_POSTPONED_LEN VALKEYMODULE_POSTPONED_LEN +#define REDISMODULE_NO_EXPIRE VALKEYMODULE_NO_EXPIRE +#define REDISMODULE_ZADD_XX VALKEYMODULE_ZADD_XX +#define REDISMODULE_ZADD_NX VALKEYMODULE_ZADD_NX +#define REDISMODULE_ZADD_ADDED VALKEYMODULE_ZADD_ADDED +#define REDISMODULE_ZADD_UPDATED VALKEYMODULE_ZADD_UPDATED +#define REDISMODULE_ZADD_NOP VALKEYMODULE_ZADD_NOP +#define REDISMODULE_ZADD_GT VALKEYMODULE_ZADD_GT +#define REDISMODULE_ZADD_LT VALKEYMODULE_ZADD_LT +#define REDISMODULE_HASH_NONE VALKEYMODULE_HASH_NONE +#define REDISMODULE_HASH_NX VALKEYMODULE_HASH_NX +#define REDISMODULE_HASH_XX VALKEYMODULE_HASH_XX +#define REDISMODULE_HASH_CFIELDS VALKEYMODULE_HASH_CFIELDS +#define REDISMODULE_HASH_EXISTS VALKEYMODULE_HASH_EXISTS +#define REDISMODULE_HASH_COUNT_ALL VALKEYMODULE_HASH_COUNT_ALL +#define REDISMODULE_CONFIG_DEFAULT VALKEYMODULE_CONFIG_DEFAULT +#define REDISMODULE_CONFIG_IMMUTABLE VALKEYMODULE_CONFIG_IMMUTABLE +#define REDISMODULE_CONFIG_SENSITIVE VALKEYMODULE_CONFIG_SENSITIVE +#define REDISMODULE_CONFIG_HIDDEN VALKEYMODULE_CONFIG_HIDDEN +#define REDISMODULE_CONFIG_PROTECTED VALKEYMODULE_CONFIG_PROTECTED +#define REDISMODULE_CONFIG_DENY_LOADING VALKEYMODULE_CONFIG_DENY_LOADING +#define REDISMODULE_CONFIG_MEMORY VALKEYMODULE_CONFIG_MEMORY +#define REDISMODULE_CONFIG_BITFLAGS VALKEYMODULE_CONFIG_BITFLAGS +#define REDISMODULE_STREAM_ADD_AUTOID VALKEYMODULE_STREAM_ADD_AUTOID +#define REDISMODULE_STREAM_ITERATOR_EXCLUSIVE VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE +#define REDISMODULE_STREAM_ITERATOR_REVERSE VALKEYMODULE_STREAM_ITERATOR_REVERSE +#define REDISMODULE_STREAM_TRIM_APPROX VALKEYMODULE_STREAM_TRIM_APPROX +#define REDISMODULE_CTX_FLAGS_LUA VALKEYMODULE_CTX_FLAGS_LUA +#define REDISMODULE_CTX_FLAGS_MULTI VALKEYMODULE_CTX_FLAGS_MULTI +#define REDISMODULE_CTX_FLAGS_MASTER VALKEYMODULE_CTX_FLAGS_PRIMARY +#define REDISMODULE_CTX_FLAGS_SLAVE VALKEYMODULE_CTX_FLAGS_REPLICA +#define REDISMODULE_CTX_FLAGS_READONLY VALKEYMODULE_CTX_FLAGS_READONLY +#define REDISMODULE_CTX_FLAGS_CLUSTER VALKEYMODULE_CTX_FLAGS_CLUSTER +#define REDISMODULE_CTX_FLAGS_AOF VALKEYMODULE_CTX_FLAGS_AOF +#define REDISMODULE_CTX_FLAGS_RDB VALKEYMODULE_CTX_FLAGS_RDB +#define REDISMODULE_CTX_FLAGS_MAXMEMORY VALKEYMODULE_CTX_FLAGS_MAXMEMORY +#define REDISMODULE_CTX_FLAGS_EVICT VALKEYMODULE_CTX_FLAGS_EVICT +#define REDISMODULE_CTX_FLAGS_OOM VALKEYMODULE_CTX_FLAGS_OOM +#define REDISMODULE_CTX_FLAGS_OOM_WARNING VALKEYMODULE_CTX_FLAGS_OOM_WARNING +#define REDISMODULE_CTX_FLAGS_REPLICATED VALKEYMODULE_CTX_FLAGS_REPLICATED +#define REDISMODULE_CTX_FLAGS_LOADING VALKEYMODULE_CTX_FLAGS_LOADING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_STALE VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING +#define REDISMODULE_CTX_FLAGS_REPLICA_IS_ONLINE VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE +#define REDISMODULE_CTX_FLAGS_ACTIVE_CHILD VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD +#define REDISMODULE_CTX_FLAGS_MULTI_DIRTY VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY +#define REDISMODULE_CTX_FLAGS_IS_CHILD VALKEYMODULE_CTX_FLAGS_IS_CHILD +#define REDISMODULE_CTX_FLAGS_DENY_BLOCKING VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING +#define REDISMODULE_CTX_FLAGS_RESP3 VALKEYMODULE_CTX_FLAGS_RESP3 +#define REDISMODULE_CTX_FLAGS_ASYNC_LOADING VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING +#define REDISMODULE_CTX_FLAGS_SERVER_STARTUP VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP +#define REDISMODULE_NOTIFY_KEYSPACE VALKEYMODULE_NOTIFY_KEYSPACE +#define REDISMODULE_NOTIFY_KEYEVENT VALKEYMODULE_NOTIFY_KEYEVENT +#define REDISMODULE_NOTIFY_GENERIC VALKEYMODULE_NOTIFY_GENERIC +#define REDISMODULE_NOTIFY_STRING VALKEYMODULE_NOTIFY_STRING +#define REDISMODULE_NOTIFY_LIST VALKEYMODULE_NOTIFY_LIST +#define REDISMODULE_NOTIFY_SET VALKEYMODULE_NOTIFY_SET +#define REDISMODULE_NOTIFY_HASH VALKEYMODULE_NOTIFY_HASH +#define REDISMODULE_NOTIFY_ZSET VALKEYMODULE_NOTIFY_ZSET +#define REDISMODULE_NOTIFY_EXPIRED VALKEYMODULE_NOTIFY_EXPIRED +#define REDISMODULE_NOTIFY_EVICTED VALKEYMODULE_NOTIFY_EVICTED +#define REDISMODULE_NOTIFY_STREAM VALKEYMODULE_NOTIFY_STREAM +#define REDISMODULE_NOTIFY_KEY_MISS VALKEYMODULE_NOTIFY_KEY_MISS +#define REDISMODULE_NOTIFY_LOADED VALKEYMODULE_NOTIFY_LOADED +#define REDISMODULE_NOTIFY_MODULE VALKEYMODULE_NOTIFY_MODULE +#define REDISMODULE_NOTIFY_NEW VALKEYMODULE_NOTIFY_NEW +#define REDISMODULE_NOTIFY_ALL VALKEYMODULE_NOTIFY_ALL +#define REDISMODULE_HASH_DELETE VALKEYMODULE_HASH_DELETE +#define REDISMODULE_ERRORMSG_WRONGTYPE VALKEYMODULE_ERRORMSG_WRONGTYPE +#define REDISMODULE_POSITIVE_INFINITE VALKEYMODULE_POSITIVE_INFINITE +#define REDISMODULE_NEGATIVE_INFINITE VALKEYMODULE_NEGATIVE_INFINITE +#define REDISMODULE_NODE_ID_LEN VALKEYMODULE_NODE_ID_LEN +#define REDISMODULE_NODE_MYSELF VALKEYMODULE_NODE_MYSELF +#define REDISMODULE_NODE_MASTER VALKEYMODULE_NODE_PRIMARY +#define REDISMODULE_NODE_SLAVE VALKEYMODULE_NODE_REPLICA +#define REDISMODULE_NODE_PFAIL VALKEYMODULE_NODE_PFAIL +#define REDISMODULE_NODE_FAIL VALKEYMODULE_NODE_FAIL +#define REDISMODULE_NODE_NOFAILOVER VALKEYMODULE_NODE_NOFAILOVER +#define REDISMODULE_CLUSTER_FLAG_NONE VALKEYMODULE_CLUSTER_FLAG_NONE +#define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER +#define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION +#define REDISMODULE_NOT_USED(V) VALKEYMODULE_NOT_USED(V) +#define REDISMODULE_LOGLEVEL_DEBUG VALKEYMODULE_LOGLEVEL_DEBUG +#define REDISMODULE_LOGLEVEL_VERBOSE VALKEYMODULE_LOGLEVEL_VERBOSE +#define REDISMODULE_LOGLEVEL_NOTICE VALKEYMODULE_LOGLEVEL_NOTICE +#define REDISMODULE_LOGLEVEL_WARNING VALKEYMODULE_LOGLEVEL_WARNING +#define REDISMODULE_AUX_BEFORE_RDB VALKEYMODULE_AUX_BEFORE_RDB +#define REDISMODULE_AUX_AFTER_RDB VALKEYMODULE_AUX_AFTER_RDB +#define REDISMODULE_YIELD_FLAG_NONE VALKEYMODULE_YIELD_FLAG_NONE +#define REDISMODULE_YIELD_FLAG_CLIENTS VALKEYMODULE_YIELD_FLAG_CLIENTS +#define REDISMODULE_BLOCK_UNBLOCK_DEFAULT VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT +#define REDISMODULE_BLOCK_UNBLOCK_DELETED VALKEYMODULE_BLOCK_UNBLOCK_DELETED +#define REDISMODULE_CMDFILTER_NOSELF VALKEYMODULE_CMDFILTER_NOSELF +#define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS +#define REDISMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED +#define REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD +#define REDISMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS +#define REDISMODULE_CMD_ARG_NONE VALKEYMODULE_CMD_ARG_NONE +#define REDISMODULE_CMD_ARG_OPTIONAL VALKEYMODULE_CMD_ARG_OPTIONAL +#define REDISMODULE_CMD_ARG_MULTIPLE VALKEYMODULE_CMD_ARG_MULTIPLE +#define REDISMODULE_CMD_ARG_MULTIPLE_TOKEN VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN +#define REDISMODULE_CMD_KEY_RO VALKEYMODULE_CMD_KEY_RO +#define REDISMODULE_CMD_KEY_RW VALKEYMODULE_CMD_KEY_RW +#define REDISMODULE_CMD_KEY_OW VALKEYMODULE_CMD_KEY_OW +#define REDISMODULE_CMD_KEY_RM VALKEYMODULE_CMD_KEY_RM +#define REDISMODULE_CMD_KEY_ACCESS VALKEYMODULE_CMD_KEY_ACCESS +#define REDISMODULE_CMD_KEY_UPDATE VALKEYMODULE_CMD_KEY_UPDATE +#define REDISMODULE_CMD_KEY_INSERT VALKEYMODULE_CMD_KEY_INSERT +#define REDISMODULE_CMD_KEY_DELETE VALKEYMODULE_CMD_KEY_DELETE +#define REDISMODULE_CMD_KEY_NOT_KEY VALKEYMODULE_CMD_KEY_NOT_KEY +#define REDISMODULE_CMD_KEY_INCOMPLETE VALKEYMODULE_CMD_KEY_INCOMPLETE +#define REDISMODULE_CMD_KEY_VARIABLE_FLAGS VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS +#define REDISMODULE_CMD_CHANNEL_PATTERN VALKEYMODULE_CMD_CHANNEL_PATTERN +#define REDISMODULE_CMD_CHANNEL_PUBLISH VALKEYMODULE_CMD_CHANNEL_PUBLISH +#define REDISMODULE_CMD_CHANNEL_SUBSCRIBE VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE +#define REDISMODULE_CMD_CHANNEL_UNSUBSCRIBE VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE +#define REDISMODULE_COMMAND_INFO_VERSION VALKEYMODULE_COMMAND_INFO_VERSION +#define REDISMODULE_EVENTLOOP_READABLE VALKEYMODULE_EVENTLOOP_READABLE +#define REDISMODULE_EVENTLOOP_WRITABLE VALKEYMODULE_EVENTLOOP_WRITABLE +#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED +#define REDISMODULE_EVENT_PERSISTENCE VALKEYMODULE_EVENT_PERSISTENCE +#define REDISMODULE_EVENT_FLUSHDB VALKEYMODULE_EVENT_FLUSHDB +#define REDISMODULE_EVENT_LOADING VALKEYMODULE_EVENT_LOADING +#define REDISMODULE_EVENT_CLIENT_CHANGE VALKEYMODULE_EVENT_CLIENT_CHANGE +#define REDISMODULE_EVENT_SHUTDOWN VALKEYMODULE_EVENT_SHUTDOWN +#define REDISMODULE_EVENT_REPLICA_CHANGE VALKEYMODULE_EVENT_REPLICA_CHANGE +#define REDISMODULE_EVENT_MASTER_LINK_CHANGE VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE +#define REDISMODULE_EVENT_CRON_LOOP VALKEYMODULE_EVENT_CRON_LOOP +#define REDISMODULE_EVENT_MODULE_CHANGE VALKEYMODULE_EVENT_MODULE_CHANGE +#define REDISMODULE_EVENT_LOADING_PROGRESS VALKEYMODULE_EVENT_LOADING_PROGRESS +#define REDISMODULE_EVENT_SWAPDB VALKEYMODULE_EVENT_SWAPDB +#define REDISMODULE_EVENT_REPL_BACKUP VALKEYMODULE_EVENT_REPL_BACKUP +#define REDISMODULE_EVENT_FORK_CHILD VALKEYMODULE_EVENT_FORK_CHILD +#define REDISMODULE_EVENT_REPL_ASYNC_LOAD VALKEYMODULE_EVENT_REPL_ASYNC_LOAD +#define REDISMODULE_EVENT_EVENTLOOP VALKEYMODULE_EVENT_EVENTLOOP +#define REDISMODULE_EVENT_CONFIG VALKEYMODULE_EVENT_CONFIG +#define REDISMODULE_EVENT_KEY VALKEYMODULE_EVENT_KEY +#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START +#define REDISMODULE_SUBEVENT_PERSISTENCE_ENDED VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED +#define REDISMODULE_SUBEVENT_PERSISTENCE_FAILED VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED +#define REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START +#define REDISMODULE_SUBEVENT_LOADING_RDB_START VALKEYMODULE_SUBEVENT_LOADING_RDB_START +#define REDISMODULE_SUBEVENT_LOADING_AOF_START VALKEYMODULE_SUBEVENT_LOADING_AOF_START +#define REDISMODULE_SUBEVENT_LOADING_REPL_START VALKEYMODULE_SUBEVENT_LOADING_REPL_START +#define REDISMODULE_SUBEVENT_LOADING_ENDED VALKEYMODULE_SUBEVENT_LOADING_ENDED +#define REDISMODULE_SUBEVENT_LOADING_FAILED VALKEYMODULE_SUBEVENT_LOADING_FAILED +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED +#define REDISMODULE_SUBEVENT_MASTER_LINK_UP VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP +#define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE +#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY +#define REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA +#define REDISMODULE_SUBEVENT_FLUSHDB_START VALKEYMODULE_SUBEVENT_FLUSHDB_START +#define REDISMODULE_SUBEVENT_FLUSHDB_END VALKEYMODULE_SUBEVENT_FLUSHDB_END +#define REDISMODULE_SUBEVENT_MODULE_LOADED VALKEYMODULE_SUBEVENT_MODULE_LOADED +#define REDISMODULE_SUBEVENT_MODULE_UNLOADED VALKEYMODULE_SUBEVENT_MODULE_UNLOADED +#define REDISMODULE_SUBEVENT_CONFIG_CHANGE VALKEYMODULE_SUBEVENT_CONFIG_CHANGE +#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_RDB VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB +#define REDISMODULE_SUBEVENT_LOADING_PROGRESS_AOF VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF +#define REDISMODULE_SUBEVENT_REPL_BACKUP_CREATE VALKEYMODULE_SUBEVENT_REPL_BACKUP_CREATE +#define REDISMODULE_SUBEVENT_REPL_BACKUP_RESTORE VALKEYMODULE_SUBEVENT_REPL_BACKUP_RESTORE +#define REDISMODULE_SUBEVENT_REPL_BACKUP_DISCARD VALKEYMODULE_SUBEVENT_REPL_BACKUP_DISCARD +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED +#define REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED +#define REDISMODULE_SUBEVENT_FORK_CHILD_BORN VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN +#define REDISMODULE_SUBEVENT_FORK_CHILD_DIED VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED +#define REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP +#define REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP +#define REDISMODULE_SUBEVENT_KEY_DELETED VALKEYMODULE_SUBEVENT_KEY_DELETED +#define REDISMODULE_SUBEVENT_KEY_EXPIRED VALKEYMODULE_SUBEVENT_KEY_EXPIRED +#define REDISMODULE_SUBEVENT_KEY_EVICTED VALKEYMODULE_SUBEVENT_KEY_EVICTED +#define REDISMODULE_SUBEVENT_KEY_OVERWRITTEN VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN +#define REDISMODULE_CLIENTINFO_FLAG_SSL VALKEYMODULE_CLIENTINFO_FLAG_SSL +#define REDISMODULE_CLIENTINFO_FLAG_PUBSUB VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB +#define REDISMODULE_CLIENTINFO_FLAG_BLOCKED VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED +#define REDISMODULE_CLIENTINFO_FLAG_TRACKING VALKEYMODULE_CLIENTINFO_FLAG_TRACKING +#define REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET +#define REDISMODULE_CLIENTINFO_FLAG_MULTI VALKEYMODULE_CLIENTINFO_FLAG_MULTI +#define REDISMODULE_CLIENTINFO_VERSION VALKEYMODULE_CLIENTINFO_VERSION +#define REDISMODULE_CLIENTINFO_INITIALIZER_V1 VALKEYMODULE_CLIENTINFO_INITIALIZER_V1 +#define REDISMODULE_REPLICATIONINFO_VERSION VALKEYMODULE_REPLICATIONINFO_VERSION +#define REDISMODULE_FLUSHINFO_VERSION VALKEYMODULE_FLUSHINFO_VERSION +#define REDISMODULE_MODULE_CHANGE_VERSION VALKEYMODULE_MODULE_CHANGE_VERSION +#define REDISMODULE_CONFIGCHANGE_VERSION VALKEYMODULE_CONFIGCHANGE_VERSION +#define REDISMODULE_CRON_LOOP_VERSION VALKEYMODULE_CRON_LOOP_VERSION +#define REDISMODULE_LOADING_PROGRESS_VERSION VALKEYMODULE_LOADING_PROGRESS_VERSION +#define REDISMODULE_SWAPDBINFO_VERSION VALKEYMODULE_SWAPDBINFO_VERSION +#define REDISMODULE_KEYINFO_VERSION VALKEYMODULE_KEYINFO_VERSION +#define REDISMODULE_GET_API(name) VALKEYMODULE_GET_API(name) +#define REDISMODULE_API VALKEYMODULE_API +#define REDISMODULE_ATTR VALKEYMODULE_ATTR + +#define REDISMODULE_ACL_LOG_AUTH VALKEYMODULE_ACL_LOG_AUTH +#define REDISMODULE_ACL_LOG_CMD VALKEYMODULE_ACL_LOG_CMD +#define REDISMODULE_ACL_LOG_KEY VALKEYMODULE_ACL_LOG_KEY +#define REDISMODULE_ACL_LOG_CHANNEL VALKEYMODULE_ACL_LOG_CHANNEL + +#define REDISMODULE_KSPEC_BS_INVALID VALKEYMODULE_KSPEC_BS_INVALID +#define REDISMODULE_KSPEC_BS_UNKNOWN VALKEYMODULE_KSPEC_BS_UNKNOWN +#define REDISMODULE_KSPEC_BS_INDEX VALKEYMODULE_KSPEC_BS_INDEX +#define REDISMODULE_KSPEC_BS_KEYWORD VALKEYMODULE_KSPEC_BS_KEYWORD + +#define REDISMODULE_KSPEC_FK_OMITTED VALKEYMODULE_KSPEC_FK_OMITTED +#define REDISMODULE_KSPEC_FK_UNKNOWN VALKEYMODULE_KSPEC_FK_UNKNOWN +#define REDISMODULE_KSPEC_FK_RANGE VALKEYMODULE_KSPEC_FK_RANGE +#define REDISMODULE_KSPEC_FK_KEYNUM VALKEYMODULE_KSPEC_FK_KEYNUM + +#define REDISMODULE_ARG_TYPE_STRING VALKEYMODULE_ARG_TYPE_STRING +#define REDISMODULE_ARG_TYPE_INTEGER VALKEYMODULE_ARG_TYPE_INTEGER +#define REDISMODULE_ARG_TYPE_DOUBLE VALKEYMODULE_ARG_TYPE_DOUBLE +#define REDISMODULE_ARG_TYPE_KEY VALKEYMODULE_ARG_TYPE_KEY +#define REDISMODULE_ARG_TYPE_PATTERN VALKEYMODULE_ARG_TYPE_PATTERN +#define REDISMODULE_ARG_TYPE_UNIX_TIME VALKEYMODULE_ARG_TYPE_UNIX_TIME +#define REDISMODULE_ARG_TYPE_PURE_TOKEN VALKEYMODULE_ARG_TYPE_PURE_TOKEN +#define REDISMODULE_ARG_TYPE_ONEOF VALKEYMODULE_ARG_TYPE_ONEOF +#define REDISMODULE_ARG_TYPE_BLOCK VALKEYMODULE_ARG_TYPE_BLOCK + +/* RedisModule typedefs */ +#define RedisModuleString ValkeyModuleString +#define RedisModuleKey ValkeyModuleKey +#define RedisModuleStreamID ValkeyModuleStreamID +#define RedisModuleCommandArg ValkeyModuleCommandArg +#define RedisModuleEvent ValkeyModuleEvent +#define RedisModuleClientInfo ValkeyModuleClientInfo +#define RedisModuleReplicationInfo ValkeyModuleReplicationInfo +#define RedisModuleFlushInfo ValkeyModuleFlushInfo +#define RedisModuleModuleChange ValkeyModuleModuleChange +#define RedisModuleConfigChange ValkeyModuleConfigChange +#define RedisModuleCronLoopInfo ValkeyModuleCronLoopInfo +#define RedisModuleLoadingProgressInfo ValkeyModuleLoadingProgressInfo +#define RedisModuleSwapDbInfo ValkeyModuleSwapDbInfo +#define RedisModuleKeyInfo ValkeyModuleKeyInfo +#define RedisModuleIO ValkeyModuleIO +#define RedisModuleDigest ValkeyModuleDigest +#define RedisModuleInfoCtx ValkeyModuleInfoCtx +#define RedisModuleDefragCtx ValkeyModuleDefragCtx +#define RedisModuleCtx ValkeyModuleCtx +#define RedisModuleCommand ValkeyModuleCommand +#define RedisModuleCallReply ValkeyModuleCallReply +#define RedisModuleType ValkeyModuleType +#define RedisModuleBlockedClient ValkeyModuleBlockedClient +#define RedisModuleClusterInfo ValkeyModuleClusterInfo +#define RedisModuleDict ValkeyModuleDict +#define RedisModuleDictIter ValkeyModuleDictIter +#define RedisModuleCommandFilterCtx ValkeyModuleCommandFilterCtx +#define RedisModuleCommandFilter ValkeyModuleCommandFilter +#define RedisModuleServerInfoData ValkeyModuleServerInfoData +#define RedisModuleScanCursor ValkeyModuleScanCursor +#define RedisModuleUser ValkeyModuleUser +#define RedisModuleKeyOptCtx ValkeyModuleKeyOptCtx +#define RedisModuleRdbStream ValkeyModuleRdbStream +#define RedisModuleTypeMethods ValkeyModuleTypeMethods +#define RedisModuleTimerID ValkeyModuleTimerID +#define RedisModuleClientInfo ValkeyModuleClientInfo +#define RedisModuleClientInfoV1 ValkeyModuleClientInfoV1 +#define RedisModuleLoadingProgress ValkeyModuleLoadingProgress +#define RedisModuleCronLoop ValkeyModuleCronLoop +#define RedisModuleConfigChangeV1 ValkeyModuleConfigChangeV1 +#define RedisModuleKeyInfoV1 ValkeyModuleKeyInfoV1 +#define RedisModuleCommandInfo ValkeyModuleCommandInfo +#define RedisModuleCommandKeySpec ValkeyModuleCommandKeySpec +#define RedisModuleCommandHistoryEntry ValkeyModuleCommandHistoryEntry + +/* RedisModule APIs */ +#define RedisModule_OnLoad ValkeyModule_OnLoad +#define RedisModule_Init ValkeyModule_Init +#define RedisModule_Assert ValkeyModule_Assert +#define RedisModule_Alloc ValkeyModule_Alloc +#define RedisModule_TryAlloc ValkeyModule_TryAlloc +#define RedisModule_Realloc ValkeyModule_Realloc +#define RedisModule_TryRealloc ValkeyModule_TryRealloc +#define RedisModule_Free ValkeyModule_Free +#define RedisModule_Calloc ValkeyModule_Calloc +#define RedisModule_TryCalloc ValkeyModule_TryCalloc +#define RedisModule_Strdup ValkeyModule_Strdup +#define RedisModule_GetApi ValkeyModule_GetApi +#define RedisModule_CreateCommand ValkeyModule_CreateCommand +#define RedisModule_GetCommand ValkeyModule_GetCommand +#define RedisModule_CreateSubcommand ValkeyModule_CreateSubcommand +#define RedisModule_SetCommandInfo ValkeyModule_SetCommandInfo +#define RedisModule_SetCommandACLCategories ValkeyModule_SetCommandACLCategories +#define RedisModule_AddACLCategory ValkeyModule_AddACLCategory +#define RedisModule_SetModuleAttribs ValkeyModule_SetModuleAttribs +#define RedisModule_IsModuleNameBusy ValkeyModule_IsModuleNameBusy +#define RedisModule_WrongArity ValkeyModule_WrongArity +#define RedisModule_ReplyWithLongLong ValkeyModule_ReplyWithLongLong +#define RedisModule_GetSelectedDb ValkeyModule_GetSelectedDb +#define RedisModule_SelectDb ValkeyModule_SelectDb +#define RedisModule_KeyExists ValkeyModule_KeyExists +#define RedisModule_OpenKey ValkeyModule_OpenKey +#define RedisModule_GetOpenKeyModesAll ValkeyModule_GetOpenKeyModesAll +#define RedisModule_CloseKey ValkeyModule_CloseKey +#define RedisModule_KeyType ValkeyModule_KeyType +#define RedisModule_ValueLength ValkeyModule_ValueLength +#define RedisModule_ListPush ValkeyModule_ListPush +#define RedisModule_ListPop ValkeyModule_ListPop +#define RedisModule_ListGet ValkeyModule_ListGet +#define RedisModule_ListSet ValkeyModule_ListSet +#define RedisModule_ListInsert ValkeyModule_ListInsert +#define RedisModule_ListDelete ValkeyModule_ListDelete +#define RedisModule_Call ValkeyModule_Call +#define RedisModule_CallReplyProto ValkeyModule_CallReplyProto +#define RedisModule_FreeCallReply ValkeyModule_FreeCallReply +#define RedisModule_CallReplyType ValkeyModule_CallReplyType +#define RedisModule_CallReplyInteger ValkeyModule_CallReplyInteger +#define RedisModule_CallReplyDouble ValkeyModule_CallReplyDouble +#define RedisModule_CallReplyBool ValkeyModule_CallReplyBool +#define RedisModule_CallReplyBigNumber ValkeyModule_CallReplyBigNumber +#define RedisModule_CallReplyVerbatim ValkeyModule_CallReplyVerbatim +#define RedisModule_CallReplySetElement ValkeyModule_CallReplySetElement +#define RedisModule_CallReplyMapElement ValkeyModule_CallReplyMapElement +#define RedisModule_CallReplyAttributeElement ValkeyModule_CallReplyAttributeElement +#define RedisModule_CallReplyPromiseSetUnblockHandler ValkeyModule_CallReplyPromiseSetUnblockHandler +#define RedisModule_CallReplyPromiseAbort ValkeyModule_CallReplyPromiseAbort +#define RedisModule_CallReplyAttribute ValkeyModule_CallReplyAttribute +#define RedisModule_CallReplyLength ValkeyModule_CallReplyLength +#define RedisModule_CallReplyArrayElement ValkeyModule_CallReplyArrayElement +#define RedisModule_CreateString ValkeyModule_CreateString +#define RedisModule_CreateStringFromLongLong ValkeyModule_CreateStringFromLongLong +#define RedisModule_CreateStringFromULongLong ValkeyModule_CreateStringFromULongLong +#define RedisModule_CreateStringFromDouble ValkeyModule_CreateStringFromDouble +#define RedisModule_CreateStringFromLongDouble ValkeyModule_CreateStringFromLongDouble +#define RedisModule_CreateStringFromString ValkeyModule_CreateStringFromString +#define RedisModule_CreateStringFromStreamID ValkeyModule_CreateStringFromStreamID +#define RedisModule_CreateStringPrintf ValkeyModule_CreateStringPrintf +#define RedisModule_FreeString ValkeyModule_FreeString +#define RedisModule_StringPtrLen ValkeyModule_StringPtrLen +#define RedisModule_ReplyWithError ValkeyModule_ReplyWithError +#define RedisModule_ReplyWithErrorFormat ValkeyModule_ReplyWithErrorFormat +#define RedisModule_ReplyWithSimpleString ValkeyModule_ReplyWithSimpleString +#define RedisModule_ReplyWithArray ValkeyModule_ReplyWithArray +#define RedisModule_ReplyWithMap ValkeyModule_ReplyWithMap +#define RedisModule_ReplyWithSet ValkeyModule_ReplyWithSet +#define RedisModule_ReplyWithAttribute ValkeyModule_ReplyWithAttribute +#define RedisModule_ReplyWithNullArray ValkeyModule_ReplyWithNullArray +#define RedisModule_ReplyWithEmptyArray ValkeyModule_ReplyWithEmptyArray +#define RedisModule_ReplySetArrayLength ValkeyModule_ReplySetArrayLength +#define RedisModule_ReplySetMapLength ValkeyModule_ReplySetMapLength +#define RedisModule_ReplySetSetLength ValkeyModule_ReplySetSetLength +#define RedisModule_ReplySetAttributeLength ValkeyModule_ReplySetAttributeLength +#define RedisModule_ReplySetPushLength ValkeyModule_ReplySetPushLength +#define RedisModule_ReplyWithStringBuffer ValkeyModule_ReplyWithStringBuffer +#define RedisModule_ReplyWithCString ValkeyModule_ReplyWithCString +#define RedisModule_ReplyWithString ValkeyModule_ReplyWithString +#define RedisModule_ReplyWithEmptyString ValkeyModule_ReplyWithEmptyString +#define RedisModule_ReplyWithVerbatimString ValkeyModule_ReplyWithVerbatimString +#define RedisModule_ReplyWithVerbatimStringType ValkeyModule_ReplyWithVerbatimStringType +#define RedisModule_ReplyWithNull ValkeyModule_ReplyWithNull +#define RedisModule_ReplyWithBool ValkeyModule_ReplyWithBool +#define RedisModule_ReplyWithLongDouble ValkeyModule_ReplyWithLongDouble +#define RedisModule_ReplyWithDouble ValkeyModule_ReplyWithDouble +#define RedisModule_ReplyWithBigNumber ValkeyModule_ReplyWithBigNumber +#define RedisModule_ReplyWithCallReply ValkeyModule_ReplyWithCallReply +#define RedisModule_StringToLongLong ValkeyModule_StringToLongLong +#define RedisModule_StringToULongLong ValkeyModule_StringToULongLong +#define RedisModule_StringToDouble ValkeyModule_StringToDouble +#define RedisModule_StringToLongDouble ValkeyModule_StringToLongDouble +#define RedisModule_StringToStreamID ValkeyModule_StringToStreamID +#define RedisModule_AutoMemory ValkeyModule_AutoMemory +#define RedisModule_Replicate ValkeyModule_Replicate +#define RedisModule_ReplicateVerbatim ValkeyModule_ReplicateVerbatim +#define RedisModule_CallReplyStringPtr ValkeyModule_CallReplyStringPtr +#define RedisModule_CreateStringFromCallReply ValkeyModule_CreateStringFromCallReply +#define RedisModule_DeleteKey ValkeyModule_DeleteKey +#define RedisModule_UnlinkKey ValkeyModule_UnlinkKey +#define RedisModule_StringSet ValkeyModule_StringSet +#define RedisModule_StringDMA ValkeyModule_StringDMA +#define RedisModule_StringTruncate ValkeyModule_StringTruncate +#define RedisModule_GetExpire ValkeyModule_GetExpire +#define RedisModule_SetExpire ValkeyModule_SetExpire +#define RedisModule_GetAbsExpire ValkeyModule_GetAbsExpire +#define RedisModule_SetAbsExpire ValkeyModule_SetAbsExpire +#define RedisModule_ResetDataset ValkeyModule_ResetDataset +#define RedisModule_DbSize ValkeyModule_DbSize +#define RedisModule_RandomKey ValkeyModule_RandomKey +#define RedisModule_ZsetAdd ValkeyModule_ZsetAdd +#define RedisModule_ZsetIncrby ValkeyModule_ZsetIncrby +#define RedisModule_ZsetScore ValkeyModule_ZsetScore +#define RedisModule_ZsetRem ValkeyModule_ZsetRem +#define RedisModule_ZsetRangeStop ValkeyModule_ZsetRangeStop +#define RedisModule_ZsetFirstInScoreRange ValkeyModule_ZsetFirstInScoreRange +#define RedisModule_ZsetLastInScoreRange ValkeyModule_ZsetLastInScoreRange +#define RedisModule_ZsetFirstInLexRange ValkeyModule_ZsetFirstInLexRange +#define RedisModule_ZsetLastInLexRange ValkeyModule_ZsetLastInLexRange +#define RedisModule_ZsetRangeCurrentElement ValkeyModule_ZsetRangeCurrentElement +#define RedisModule_ZsetRangeNext ValkeyModule_ZsetRangeNext +#define RedisModule_ZsetRangePrev ValkeyModule_ZsetRangePrev +#define RedisModule_ZsetRangeEndReached ValkeyModule_ZsetRangeEndReached +#define RedisModule_HashSet ValkeyModule_HashSet +#define RedisModule_HashGet ValkeyModule_HashGet +#define RedisModule_StreamAdd ValkeyModule_StreamAdd +#define RedisModule_StreamDelete ValkeyModule_StreamDelete +#define RedisModule_StreamIteratorStart ValkeyModule_StreamIteratorStart +#define RedisModule_StreamIteratorStop ValkeyModule_StreamIteratorStop +#define RedisModule_StreamIteratorNextID ValkeyModule_StreamIteratorNextID +#define RedisModule_StreamIteratorNextField ValkeyModule_StreamIteratorNextField +#define RedisModule_StreamIteratorDelete ValkeyModule_StreamIteratorDelete +#define RedisModule_StreamTrimByLength ValkeyModule_StreamTrimByLength +#define RedisModule_StreamTrimByID ValkeyModule_StreamTrimByID +#define RedisModule_IsKeysPositionRequest ValkeyModule_IsKeysPositionRequest +#define RedisModule_KeyAtPos ValkeyModule_KeyAtPos +#define RedisModule_KeyAtPosWithFlags ValkeyModule_KeyAtPosWithFlags +#define RedisModule_IsChannelsPositionRequest ValkeyModule_IsChannelsPositionRequest +#define RedisModule_ChannelAtPosWithFlags ValkeyModule_ChannelAtPosWithFlags +#define RedisModule_GetClientId ValkeyModule_GetClientId +#define RedisModule_GetClientUserNameById ValkeyModule_GetClientUserNameById +#define RedisModule_GetClientInfoById ValkeyModule_GetClientInfoById +#define RedisModule_GetClientNameById ValkeyModule_GetClientNameById +#define RedisModule_SetClientNameById ValkeyModule_SetClientNameById +#define RedisModule_PublishMessage ValkeyModule_PublishMessage +#define RedisModule_PublishMessageShard ValkeyModule_PublishMessageShard +#define RedisModule_GetContextFlags ValkeyModule_GetContextFlags +#define RedisModule_AvoidReplicaTraffic ValkeyModule_AvoidReplicaTraffic +#define RedisModule_PoolAlloc ValkeyModule_PoolAlloc +#define RedisModule_CreateDataType ValkeyModule_CreateDataType +#define RedisModule_ModuleTypeSetValue ValkeyModule_ModuleTypeSetValue +#define RedisModule_ModuleTypeReplaceValue ValkeyModule_ModuleTypeReplaceValue +#define RedisModule_ModuleTypeGetType ValkeyModule_ModuleTypeGetType +#define RedisModule_ModuleTypeGetValue ValkeyModule_ModuleTypeGetValue +#define RedisModule_IsIOError ValkeyModule_IsIOError +#define RedisModule_SetModuleOptions ValkeyModule_SetModuleOptions +#define RedisModule_SignalModifiedKey ValkeyModule_SignalModifiedKey +#define RedisModule_SaveUnsigned ValkeyModule_SaveUnsigned +#define RedisModule_LoadUnsigned ValkeyModule_LoadUnsigned +#define RedisModule_SaveSigned ValkeyModule_SaveSigned +#define RedisModule_LoadSigned ValkeyModule_LoadSigned +#define RedisModule_EmitAOF ValkeyModule_EmitAOF +#define RedisModule_SaveString ValkeyModule_SaveString +#define RedisModule_SaveStringBuffer ValkeyModule_SaveStringBuffer +#define RedisModule_LoadString ValkeyModule_LoadString +#define RedisModule_LoadStringBuffer ValkeyModule_LoadStringBuffer +#define RedisModule_SaveDouble ValkeyModule_SaveDouble +#define RedisModule_LoadDouble ValkeyModule_LoadDouble +#define RedisModule_SaveFloat ValkeyModule_SaveFloat +#define RedisModule_LoadFloat ValkeyModule_LoadFloat +#define RedisModule_SaveLongDouble ValkeyModule_SaveLongDouble +#define RedisModule_LoadLongDouble ValkeyModule_LoadLongDouble +#define RedisModule_LoadDataTypeFromString ValkeyModule_LoadDataTypeFromString +#define RedisModule_LoadDataTypeFromStringEncver ValkeyModule_LoadDataTypeFromStringEncver +#define RedisModule_SaveDataTypeToString ValkeyModule_SaveDataTypeToString +#define RedisModule_Log ValkeyModule_Log +#define RedisModule_LogIOError ValkeyModule_LogIOError +#define RedisModule__Assert ValkeyModule__Assert +#define RedisModule_LatencyAddSample ValkeyModule_LatencyAddSample +#define RedisModule_StringAppendBuffer ValkeyModule_StringAppendBuffer +#define RedisModule_TrimStringAllocation ValkeyModule_TrimStringAllocation +#define RedisModule_RetainString ValkeyModule_RetainString +#define RedisModule_HoldString ValkeyModule_HoldString +#define RedisModule_StringCompare ValkeyModule_StringCompare +#define RedisModule_GetContextFromIO ValkeyModule_GetContextFromIO +#define RedisModule_GetKeyNameFromIO ValkeyModule_GetKeyNameFromIO +#define RedisModule_GetKeyNameFromModuleKey ValkeyModule_GetKeyNameFromModuleKey +#define RedisModule_GetDbIdFromModuleKey ValkeyModule_GetDbIdFromModuleKey +#define RedisModule_GetDbIdFromIO ValkeyModule_GetDbIdFromIO +#define RedisModule_GetDbIdFromOptCtx ValkeyModule_GetDbIdFromOptCtx +#define RedisModule_GetToDbIdFromOptCtx ValkeyModule_GetToDbIdFromOptCtx +#define RedisModule_GetKeyNameFromOptCtx ValkeyModule_GetKeyNameFromOptCtx +#define RedisModule_GetToKeyNameFromOptCtx ValkeyModule_GetToKeyNameFromOptCtx +#define RedisModule_Milliseconds ValkeyModule_Milliseconds +#define RedisModule_MonotonicMicroseconds ValkeyModule_MonotonicMicroseconds +#define RedisModule_Microseconds ValkeyModule_Microseconds +#define RedisModule_CachedMicroseconds ValkeyModule_CachedMicroseconds +#define RedisModule_DigestAddStringBuffer ValkeyModule_DigestAddStringBuffer +#define RedisModule_DigestAddLongLong ValkeyModule_DigestAddLongLong +#define RedisModule_DigestEndSequence ValkeyModule_DigestEndSequence +#define RedisModule_GetDbIdFromDigest ValkeyModule_GetDbIdFromDigest +#define RedisModule_GetKeyNameFromDigest ValkeyModule_GetKeyNameFromDigest +#define RedisModule_CreateDict ValkeyModule_CreateDict +#define RedisModule_FreeDict ValkeyModule_FreeDict +#define RedisModule_DictSize ValkeyModule_DictSize +#define RedisModule_DictSetC ValkeyModule_DictSetC +#define RedisModule_DictReplaceC ValkeyModule_DictReplaceC +#define RedisModule_DictSet ValkeyModule_DictSet +#define RedisModule_DictReplace ValkeyModule_DictReplace +#define RedisModule_DictGetC ValkeyModule_DictGetC +#define RedisModule_DictGet ValkeyModule_DictGet +#define RedisModule_DictDelC ValkeyModule_DictDelC +#define RedisModule_DictDel ValkeyModule_DictDel +#define RedisModule_DictIteratorStartC ValkeyModule_DictIteratorStartC +#define RedisModule_DictIteratorStart ValkeyModule_DictIteratorStart +#define RedisModule_DictIteratorStop ValkeyModule_DictIteratorStop +#define RedisModule_DictIteratorReseekC ValkeyModule_DictIteratorReseekC +#define RedisModule_DictIteratorReseek ValkeyModule_DictIteratorReseek +#define RedisModule_DictNextC ValkeyModule_DictNextC +#define RedisModule_DictPrevC ValkeyModule_DictPrevC +#define RedisModule_DictNext ValkeyModule_DictNext +#define RedisModule_DictPrev ValkeyModule_DictPrev +#define RedisModule_DictCompareC ValkeyModule_DictCompareC +#define RedisModule_DictCompare ValkeyModule_DictCompare +#define RedisModule_RegisterInfoFunc ValkeyModule_RegisterInfoFunc +#define RedisModule_RegisterAuthCallback ValkeyModule_RegisterAuthCallback +#define RedisModule_InfoAddSection ValkeyModule_InfoAddSection +#define RedisModule_InfoBeginDictField ValkeyModule_InfoBeginDictField +#define RedisModule_InfoEndDictField ValkeyModule_InfoEndDictField +#define RedisModule_InfoAddFieldString ValkeyModule_InfoAddFieldString +#define RedisModule_InfoAddFieldCString ValkeyModule_InfoAddFieldCString +#define RedisModule_InfoAddFieldDouble ValkeyModule_InfoAddFieldDouble +#define RedisModule_InfoAddFieldLongLong ValkeyModule_InfoAddFieldLongLong +#define RedisModule_InfoAddFieldULongLong ValkeyModule_InfoAddFieldULongLong +#define RedisModule_GetServerInfo ValkeyModule_GetServerInfo +#define RedisModule_FreeServerInfo ValkeyModule_FreeServerInfo +#define RedisModule_ServerInfoGetField ValkeyModule_ServerInfoGetField +#define RedisModule_ServerInfoGetFieldC ValkeyModule_ServerInfoGetFieldC +#define RedisModule_ServerInfoGetFieldSigned ValkeyModule_ServerInfoGetFieldSigned +#define RedisModule_ServerInfoGetFieldUnsigned ValkeyModule_ServerInfoGetFieldUnsigned +#define RedisModule_ServerInfoGetFieldDouble ValkeyModule_ServerInfoGetFieldDouble +#define RedisModule_SubscribeToServerEvent ValkeyModule_SubscribeToServerEvent +#define RedisModule_SetLRU ValkeyModule_SetLRU +#define RedisModule_GetLRU ValkeyModule_GetLRU +#define RedisModule_SetLFU ValkeyModule_SetLFU +#define RedisModule_GetLFU ValkeyModule_GetLFU +#define RedisModule_BlockClientOnKeys ValkeyModule_BlockClientOnKeys +#define RedisModule_BlockClientOnKeysWithFlags ValkeyModule_BlockClientOnKeysWithFlags +#define RedisModule_SignalKeyAsReady ValkeyModule_SignalKeyAsReady +#define RedisModule_GetBlockedClientReadyKey ValkeyModule_GetBlockedClientReadyKey +#define RedisModule_ScanCursorCreate ValkeyModule_ScanCursorCreate +#define RedisModule_ScanCursorRestart ValkeyModule_ScanCursorRestart +#define RedisModule_ScanCursorDestroy ValkeyModule_ScanCursorDestroy +#define RedisModule_Scan ValkeyModule_Scan +#define RedisModule_ScanKey ValkeyModule_ScanKey +#define RedisModule_GetContextFlagsAll ValkeyModule_GetContextFlagsAll +#define RedisModule_GetModuleOptionsAll ValkeyModule_GetModuleOptionsAll +#define RedisModule_GetKeyspaceNotificationFlagsAll ValkeyModule_GetKeyspaceNotificationFlagsAll +#define RedisModule_IsSubEventSupported ValkeyModule_IsSubEventSupported +#define RedisModule_GetServerVersion ValkeyModule_GetServerVersion +#define RedisModule_GetTypeMethodVersion ValkeyModule_GetTypeMethodVersion +#define RedisModule_Yield ValkeyModule_Yield +#define RedisModule_BlockClient ValkeyModule_BlockClient +#define RedisModule_BlockClientGetPrivateData ValkeyModule_BlockClientGetPrivateData +#define RedisModule_BlockClientSetPrivateData ValkeyModule_BlockClientSetPrivateData +#define RedisModule_BlockClientOnAuth ValkeyModule_BlockClientOnAuth +#define RedisModule_UnblockClient ValkeyModule_UnblockClient +#define RedisModule_IsBlockedReplyRequest ValkeyModule_IsBlockedReplyRequest +#define RedisModule_IsBlockedTimeoutRequest ValkeyModule_IsBlockedTimeoutRequest +#define RedisModule_GetBlockedClientPrivateData ValkeyModule_GetBlockedClientPrivateData +#define RedisModule_GetBlockedClientHandle ValkeyModule_GetBlockedClientHandle +#define RedisModule_AbortBlock ValkeyModule_AbortBlock +#define RedisModule_BlockedClientMeasureTimeStart ValkeyModule_BlockedClientMeasureTimeStart +#define RedisModule_BlockedClientMeasureTimeEnd ValkeyModule_BlockedClientMeasureTimeEnd +#define RedisModule_GetThreadSafeContext ValkeyModule_GetThreadSafeContext +#define RedisModule_GetDetachedThreadSafeContext ValkeyModule_GetDetachedThreadSafeContext +#define RedisModule_FreeThreadSafeContext ValkeyModule_FreeThreadSafeContext +#define RedisModule_ThreadSafeContextLock ValkeyModule_ThreadSafeContextLock +#define RedisModule_ThreadSafeContextTryLock ValkeyModule_ThreadSafeContextTryLock +#define RedisModule_ThreadSafeContextUnlock ValkeyModule_ThreadSafeContextUnlock +#define RedisModule_SubscribeToKeyspaceEvents ValkeyModule_SubscribeToKeyspaceEvents +#define RedisModule_AddPostNotificationJob ValkeyModule_AddPostNotificationJob +#define RedisModule_NotifyKeyspaceEvent ValkeyModule_NotifyKeyspaceEvent +#define RedisModule_GetNotifyKeyspaceEvents ValkeyModule_GetNotifyKeyspaceEvents +#define RedisModule_BlockedClientDisconnected ValkeyModule_BlockedClientDisconnected +#define RedisModule_RegisterClusterMessageReceiver ValkeyModule_RegisterClusterMessageReceiver +#define RedisModule_SendClusterMessage ValkeyModule_SendClusterMessage +#define RedisModule_GetClusterNodeInfo ValkeyModule_GetClusterNodeInfo +#define RedisModule_GetClusterNodesList ValkeyModule_GetClusterNodesList +#define RedisModule_FreeClusterNodesList ValkeyModule_FreeClusterNodesList +#define RedisModule_CreateTimer ValkeyModule_CreateTimer +#define RedisModule_StopTimer ValkeyModule_StopTimer +#define RedisModule_GetTimerInfo ValkeyModule_GetTimerInfo +#define RedisModule_GetMyClusterID ValkeyModule_GetMyClusterID +#define RedisModule_GetClusterSize ValkeyModule_GetClusterSize +#define RedisModule_GetRandomBytes ValkeyModule_GetRandomBytes +#define RedisModule_GetRandomHexChars ValkeyModule_GetRandomHexChars +#define RedisModule_SetDisconnectCallback ValkeyModule_SetDisconnectCallback +#define RedisModule_SetClusterFlags ValkeyModule_SetClusterFlags +#define RedisModule_ClusterKeySlot ValkeyModule_ClusterKeySlot +#define RedisModule_ClusterCanonicalKeyNameInSlot ValkeyModule_ClusterCanonicalKeyNameInSlot +#define RedisModule_ExportSharedAPI ValkeyModule_ExportSharedAPI +#define RedisModule_GetSharedAPI ValkeyModule_GetSharedAPI +#define RedisModule_RegisterCommandFilter ValkeyModule_RegisterCommandFilter +#define RedisModule_UnregisterCommandFilter ValkeyModule_UnregisterCommandFilter +#define RedisModule_CommandFilterArgsCount ValkeyModule_CommandFilterArgsCount +#define RedisModule_CommandFilterArgGet ValkeyModule_CommandFilterArgGet +#define RedisModule_CommandFilterArgInsert ValkeyModule_CommandFilterArgInsert +#define RedisModule_CommandFilterArgReplace ValkeyModule_CommandFilterArgReplace +#define RedisModule_CommandFilterArgDelete ValkeyModule_CommandFilterArgDelete +#define RedisModule_CommandFilterGetClientId ValkeyModule_CommandFilterGetClientId +#define RedisModule_Fork ValkeyModule_Fork +#define RedisModule_SendChildHeartbeat ValkeyModule_SendChildHeartbeat +#define RedisModule_ExitFromChild ValkeyModule_ExitFromChild +#define RedisModule_KillForkChild ValkeyModule_KillForkChild +#define RedisModule_GetUsedMemoryRatio ValkeyModule_GetUsedMemoryRatio +#define RedisModule_MallocSize ValkeyModule_MallocSize +#define RedisModule_MallocUsableSize ValkeyModule_MallocUsableSize +#define RedisModule_MallocSizeString ValkeyModule_MallocSizeString +#define RedisModule_MallocSizeDict ValkeyModule_MallocSizeDict +#define RedisModule_CreateModuleUser ValkeyModule_CreateModuleUser +#define RedisModule_FreeModuleUser ValkeyModule_FreeModuleUser +#define RedisModule_SetContextUser ValkeyModule_SetContextUser +#define RedisModule_SetModuleUserACL ValkeyModule_SetModuleUserACL +#define RedisModule_SetModuleUserACLString ValkeyModule_SetModuleUserACLString +#define RedisModule_GetModuleUserACLString ValkeyModule_GetModuleUserACLString +#define RedisModule_GetCurrentUserName ValkeyModule_GetCurrentUserName +#define RedisModule_GetModuleUserFromUserName ValkeyModule_GetModuleUserFromUserName +#define RedisModule_ACLCheckCommandPermissions ValkeyModule_ACLCheckCommandPermissions +#define RedisModule_ACLCheckKeyPermissions ValkeyModule_ACLCheckKeyPermissions +#define RedisModule_ACLCheckChannelPermissions ValkeyModule_ACLCheckChannelPermissions +#define RedisModule_ACLAddLogEntry ValkeyModule_ACLAddLogEntry +#define RedisModule_ACLAddLogEntryByUserName ValkeyModule_ACLAddLogEntryByUserName +#define RedisModule_AuthenticateClientWithACLUser ValkeyModule_AuthenticateClientWithACLUser +#define RedisModule_AuthenticateClientWithUser ValkeyModule_AuthenticateClientWithUser +#define RedisModule_DeauthenticateAndCloseClient ValkeyModule_DeauthenticateAndCloseClient +#define RedisModule_RedactClientCommandArgument ValkeyModule_RedactClientCommandArgument +#define RedisModule_GetClientCertificate ValkeyModule_GetClientCertificate +#define RedisModule_GetCommandKeys ValkeyModule_GetCommandKeys +#define RedisModule_GetCommandKeysWithFlags ValkeyModule_GetCommandKeysWithFlags +#define RedisModule_GetCurrentCommandName ValkeyModule_GetCurrentCommandName +#define RedisModule_RegisterDefragFunc ValkeyModule_RegisterDefragFunc +#define RedisModule_DefragAlloc ValkeyModule_DefragAlloc +#define RedisModule_DefragRedisModuleString ValkeyModule_DefragModuleString +#define RedisModule_DefragShouldStop ValkeyModule_DefragShouldStop +#define RedisModule_DefragCursorSet ValkeyModule_DefragCursorSet +#define RedisModule_DefragCursorGet ValkeyModule_DefragCursorGet +#define RedisModule_GetDbIdFromDefragCtx ValkeyModule_GetDbIdFromDefragCtx +#define RedisModule_GetKeyNameFromDefragCtx ValkeyModule_GetKeyNameFromDefragCtx +#define RedisModule_EventLoopAdd ValkeyModule_EventLoopAdd +#define RedisModule_EventLoopDel ValkeyModule_EventLoopDel +#define RedisModule_EventLoopAddOneShot ValkeyModule_EventLoopAddOneShot +#define RedisModule_RegisterBoolConfig ValkeyModule_RegisterBoolConfig +#define RedisModule_RegisterNumericConfig ValkeyModule_RegisterNumericConfig +#define RedisModule_RegisterStringConfig ValkeyModule_RegisterStringConfig +#define RedisModule_RegisterEnumConfig ValkeyModule_RegisterEnumConfig +#define RedisModule_LoadConfigs ValkeyModule_LoadConfigs +#define RedisModule_RdbStreamCreateFromFile ValkeyModule_RdbStreamCreateFromFile +#define RedisModule_RdbStreamFree ValkeyModule_RdbStreamFree +#define RedisModule_RdbLoad ValkeyModule_RdbLoad +#define RedisModule_RdbSave ValkeyModule_RdbSave + +/* RedisModuleEvent */ +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_FlushDBV2 ValkeyModuleEvent_FlushDBV2 +#define RedisModuleEvent_FlushDBV1 ValkeyModuleEvent_FlushDBV1 +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_ReplicationRoleChanged ValkeyModuleEvent_ReplicationRoleChanged +#define RedisModuleEvent_Persistence ValkeyModuleEvent_Persistence +#define RedisModuleEvent_FlushDB ValkeyModuleEvent_FlushDB +#define RedisModuleEvent_Loading ValkeyModuleEvent_Loading +#define RedisModuleEvent_ClientChange ValkeyModuleEvent_ClientChange +#define RedisModuleEvent_Shutdown ValkeyModuleEvent_Shutdown +#define RedisModuleEvent_ReplicaChange ValkeyModuleEvent_ReplicaChange +#define RedisModuleEvent_CronLoop ValkeyModuleEvent_CronLoop +#define RedisModuleEvent_MasterLinkChange ValkeyModuleEvent_MasterLinkChange +#define RedisModuleEvent_ModuleChange ValkeyModuleEvent_ModuleChange +#define RedisModuleEvent_LoadingProgress ValkeyModuleEvent_LoadingProgress +#define RedisModuleEvent_SwapDB ValkeyModuleEvent_SwapDB +#define RedisModuleEvent_ReplAsyncLoad ValkeyModuleEvent_ReplAsyncLoad +#define RedisModuleEvent_ForkChild ValkeyModuleEvent_ForkChild +#define RedisModuleEvent_EventLoop ValkeyModuleEvent_EventLoop +#define RedisModuleEvent_Config ValkeyModuleEvent_Config +#define RedisModuleEvent_Key ValkeyModuleEvent_Key diff --git a/src/replication.c b/src/replication.c index eec67e06b1..5fb477cd8b 100644 --- a/src/replication.c +++ b/src/replication.c @@ -821,8 +821,8 @@ int masterTryPartialResynchronization(client *c, long long psync_offset) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, NULL); return C_OK; /* The caller can return, no full resync needed. */ @@ -1308,8 +1308,8 @@ int replicaPutOnline(client *slave) { refreshGoodSlavesCount(); /* Fire the replica change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE, - REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE, + VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE, NULL); serverLog(LL_NOTICE,"Synchronization with replica %s succeeded", replicationGetSlaveName(slave)); @@ -2068,8 +2068,8 @@ void readSyncBulkPayload(connection *conn) { diskless_load_tempDb = disklessLoadInitTempDb(); temp_functions_lib_ctx = functionsLibCtxCreate(); - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED, NULL); } else { replicationAttachToNewMaster(); @@ -2142,8 +2142,8 @@ void readSyncBulkPayload(connection *conn) { if (server.repl_diskless_load == REPL_DISKLESS_LOAD_SWAPDB) { /* Discard potentially partially loaded tempDb. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED, NULL); disklessLoadDiscardTempDb(diskless_load_tempDb); @@ -2173,8 +2173,8 @@ void readSyncBulkPayload(connection *conn) { /* swap existing functions ctx with the temporary one */ functionsLibCtxSwapWithCurrent(temp_functions_lib_ctx); - moduleFireServerEvent(REDISMODULE_EVENT_REPL_ASYNC_LOAD, - REDISMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED, NULL); /* Delete the old db as it's useless now. */ @@ -2269,8 +2269,8 @@ void readSyncBulkPayload(connection *conn) { server.repl_down_since = 0; /* Fire the master link modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_UP, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP, NULL); /* After a full resynchronization we use the replication ID and @@ -3044,14 +3044,14 @@ void replicationSetMaster(char *ip, int port) { } /* Fire the role change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - REDISMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA, NULL); /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); server.repl_state = REPL_STATE_CONNECT; @@ -3066,8 +3066,8 @@ void replicationUnsetMaster(void) { /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); /* Clear masterhost first, since the freeClient calls @@ -3108,8 +3108,8 @@ void replicationUnsetMaster(void) { server.repl_down_since = 0; /* Fire the role change modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, - REDISMODULE_EVENT_REPLROLECHANGED_NOW_MASTER, + moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY, NULL); /* Restart the AOF subsystem in case we shut it down during a sync when @@ -3122,8 +3122,8 @@ void replicationUnsetMaster(void) { void replicationHandleMasterDisconnection(void) { /* Fire the master link modules event. */ if (server.repl_state == REPL_STATE_CONNECTED) - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_DOWN, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN, NULL); server.master = NULL; @@ -3411,8 +3411,8 @@ void replicationResurrectCachedMaster(connection *conn) { server.repl_down_since = 0; /* Fire the master link modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_MASTER_LINK_CHANGE, - REDISMODULE_SUBEVENT_MASTER_LINK_UP, + moduleFireServerEvent(VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP, NULL); /* Re-add to the list of clients. */ diff --git a/src/server.c b/src/server.c index e2e906e69e..c41247e9dc 100644 --- a/src/server.c +++ b/src/server.c @@ -568,7 +568,7 @@ dictType objToDictDictType = { }; /* Modules system dictionary type. Keys are module name, - * values are pointer to RedisModule struct. */ + * values are pointer to ValkeyModule struct. */ dictType modulesDictType = { dictSdsCaseHash, /* hash function */ NULL, /* key dup */ @@ -677,8 +677,8 @@ void resetChildState(void) { server.stat_current_save_keys_total = 0; updateDictResizePolicy(); closeChildInfoPipe(); - moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, - REDISMODULE_SUBEVENT_FORK_CHILD_DIED, + moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD, + VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED, NULL); } @@ -1523,8 +1523,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { } /* Fire the cron loop modules event. */ - RedisModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz}; - moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP, + ValkeyModuleCronLoopV1 ei = {VALKEYMODULE_CRON_LOOP_VERSION,server.hz}; + moduleFireServerEvent(VALKEYMODULE_EVENT_CRON_LOOP, 0, &ei); @@ -1686,8 +1686,8 @@ void beforeSleep(struct aeEventLoop *eventLoop) { activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST); if (moduleCount()) { - moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP, - REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP, + moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP, + VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP, NULL); } @@ -1816,8 +1816,8 @@ void afterSleep(struct aeEventLoop *eventLoop) { atomicSet(server.module_gil_acquring, 1); moduleAcquireGIL(); atomicSet(server.module_gil_acquring, 0); - moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP, - REDISMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP, + moduleFireServerEvent(VALKEYMODULE_EVENT_EVENTLOOP, + VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP, NULL); latencyEndMonitor(latency); latencyAddSampleIfNeeded("module-acquire-GIL",latency); @@ -4502,7 +4502,7 @@ int finishShutdown(void) { if (server.aof_manifest) aofManifestFree(server.aof_manifest); /* Fire the shutdown modules event. */ - moduleFireServerEvent(REDISMODULE_EVENT_SHUTDOWN,0,NULL); + moduleFireServerEvent(VALKEYMODULE_EVENT_SHUTDOWN,0,NULL); /* Remove the pid file if possible and needed. */ if (server.daemonize || server.pidfile) { @@ -6514,8 +6514,8 @@ int serverFork(int purpose) { } updateDictResizePolicy(); - moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD, - REDISMODULE_SUBEVENT_FORK_CHILD_BORN, + moduleFireServerEvent(VALKEYMODULE_EVENT_FORK_CHILD, + VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN, NULL); } return childpid; diff --git a/src/server.h b/src/server.h index 95836def5b..0ca24e3c92 100644 --- a/src/server.h +++ b/src/server.h @@ -80,9 +80,9 @@ typedef long long ustime_t; /* microsecond time type. */ #include "rax.h" /* Radix tree */ #include "connection.h" /* Connection abstraction */ -#define REDISMODULE_CORE 1 +#define VALKEYMODULE_CORE 1 typedef struct serverObject robj; -#include "redismodule.h" /* Redis modules API defines. */ +#include "valkeymodule.h" /* Redis modules API defines. */ /* Following includes allow test functions to be called from Redis main() */ #include "zipmap.h" @@ -711,7 +711,7 @@ typedef enum { /* The "module" object type is a special one that signals that the object * is one directly managed by a Redis module. In this case the value points * to a moduleValue struct, which contains the object value (which is only - * handled by the module itself) and the RedisModuleType struct which lists + * handled by the module itself) and the ValkeyModuleType struct which lists * function pointers in order to serialize, deserialize, AOF-rewrite and * free the object. * @@ -724,53 +724,53 @@ typedef enum { #define OBJ_TYPE_MAX 7 /* Maximum number of object types */ /* Extract encver / signature from a module type ID. */ -#define REDISMODULE_TYPE_ENCVER_BITS 10 -#define REDISMODULE_TYPE_ENCVER_MASK ((1<>REDISMODULE_TYPE_ENCVER_BITS) +#define VALKEYMODULE_TYPE_ENCVER_BITS 10 +#define VALKEYMODULE_TYPE_ENCVER_MASK ((1<>VALKEYMODULE_TYPE_ENCVER_BITS) /* Bit flags for moduleTypeAuxSaveFunc */ -#define REDISMODULE_AUX_BEFORE_RDB (1<<0) -#define REDISMODULE_AUX_AFTER_RDB (1<<1) +#define VALKEYMODULE_AUX_BEFORE_RDB (1<<0) +#define VALKEYMODULE_AUX_AFTER_RDB (1<<1) -struct RedisModule; -struct RedisModuleIO; -struct RedisModuleDigest; -struct RedisModuleCtx; +struct ValkeyModule; +struct ValkeyModuleIO; +struct ValkeyModuleDigest; +struct ValkeyModuleCtx; struct moduleLoadQueueEntry; -struct RedisModuleKeyOptCtx; -struct RedisModuleCommand; +struct ValkeyModuleKeyOptCtx; +struct ValkeyModuleCommand; struct clusterState; /* Each module type implementation should export a set of methods in order * 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 serverObject *key, void *value); -typedef void (*moduleTypeDigestFunc)(struct RedisModuleDigest *digest, void *value); +typedef void *(*moduleTypeLoadFunc)(struct ValkeyModuleIO *io, int encver); +typedef void (*moduleTypeSaveFunc)(struct ValkeyModuleIO *io, void *value); +typedef int (*moduleTypeAuxLoadFunc)(struct ValkeyModuleIO *rdb, int encver, int when); +typedef void (*moduleTypeAuxSaveFunc)(struct ValkeyModuleIO *rdb, int when); +typedef void (*moduleTypeRewriteFunc)(struct ValkeyModuleIO *io, struct serverObject *key, void *value); +typedef void (*moduleTypeDigestFunc)(struct ValkeyModuleDigest *digest, void *value); typedef size_t (*moduleTypeMemUsageFunc)(const void *value); typedef void (*moduleTypeFreeFunc)(void *value); typedef size_t (*moduleTypeFreeEffortFunc)(struct serverObject *key, const void *value); typedef void (*moduleTypeUnlinkFunc)(struct serverObject *key, void *value); typedef void *(*moduleTypeCopyFunc)(struct serverObject *fromkey, struct serverObject *tokey, const void *value); -typedef int (*moduleTypeDefragFunc)(struct RedisModuleDefragCtx *ctx, struct serverObject *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 ValkeyModuleDefragCtx *ctx, struct serverObject *key, void **value); +typedef size_t (*moduleTypeMemUsageFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*moduleTypeFreeFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value); +typedef size_t (*moduleTypeFreeEffortFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void (*moduleTypeUnlinkFunc2)(struct ValkeyModuleKeyOptCtx *ctx, void *value); +typedef void *(*moduleTypeCopyFunc2)(struct ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef int (*moduleTypeAuthCallback)(struct ValkeyModuleCtx *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 ValkeyModuleType { uint64_t id; /* Higher 54 bits of type ID + 10 lower bits of encoding ver. */ - struct RedisModule *module; + struct ValkeyModule *module; moduleTypeLoadFunc rdb_load; moduleTypeSaveFunc rdb_save; moduleTypeRewriteFunc aof_rewrite; @@ -813,7 +813,7 @@ typedef struct moduleValue { } moduleValue; /* This structure represents a module inside the system. */ -struct RedisModule { +struct ValkeyModule { void *handle; /* Module dlopen() handle. */ char *name; /* Module name. */ int ver; /* Module version. We use just progressive integers. */ @@ -827,25 +827,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 ValkeyModuleBlockedClient in this module. */ + ValkeyModuleInfoFunc info_cb; /* Callback for module to add INFO fields. */ + ValkeyModuleDefragFunc 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 ValkeyModule ValkeyModule; /* 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 ValkeyModuleIO { 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 ValkeyModuleCtx *ctx; /* Optional context, see RM_GetContextFromIO()*/ struct serverObject *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 @@ -870,7 +870,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 ValkeyModuleDigest { unsigned char o[20]; /* Ordered elements. */ unsigned char x[20]; /* Xored elements. */ struct serverObject *key; /* Optional name of key processed */ @@ -1041,11 +1041,11 @@ typedef struct blockingState { long long reploffset; /* Replication offset to reach. */ /* BLOCKED_MODULE */ - void *module_blocked_handle; /* RedisModuleBlockedClient structure. + void *module_blocked_handle; /* ValkeyModuleBlockedClient structure. which is opaque for the Redis core, only handled in module.c. */ - void *async_rm_call_handle; /* RedisModuleAsyncRMCallPromise structure. + void *async_rm_call_handle; /* ValkeyModuleAsyncRMCallPromise structure. which is opaque for the Redis core, only handled in module.c. */ } blockingState; @@ -1232,13 +1232,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 ValkeyModuleBlockedClient 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 + ValkeyModuleUserChangedFunc auth_callback; /* Module callback to execute * when the authenticated user * changes. */ void *auth_callback_privdata; /* Private data that is passed when the auth @@ -2014,7 +2014,7 @@ struct valkeyServer { int cluster_module_flags; /* Set of flags that Redis modules are able to set in order to suppress certain native Redis Cluster features. Check the - REDISMODULE_CLUSTER_FLAG_*. */ + VALKEYMODULE_CLUSTER_FLAG_*. */ int cluster_allow_reads_when_down; /* Are reads allowed when the cluster is down? */ int cluster_config_file_lock_fd; /* cluster config fd, will be flocked. */ @@ -2113,7 +2113,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 ValkeyModuleKeySpecBeginSearchType */ typedef enum { KSPEC_BS_INVALID = 0, /* Must be 0 */ KSPEC_BS_UNKNOWN, @@ -2121,7 +2121,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 ValkeyModuleKeySpecFindKeysType */ typedef enum { KSPEC_FK_INVALID = 0, /* Must be 0 */ KSPEC_FK_UNKNOWN, @@ -2129,7 +2129,7 @@ typedef enum { KSPEC_FK_KEYNUM } kspec_fk_type; -/* WARNING! This struct must match RedisModuleCommandKeySpec */ +/* WARNING! This struct must match ValkeyModuleCommandKeySpec */ typedef struct { /* Declarative data */ const char *notes; @@ -2209,7 +2209,7 @@ typedef struct jsonObject { #endif -/* WARNING! This struct must match RedisModuleCommandHistoryEntry */ +/* WARNING! This struct must match ValkeyModuleCommandHistoryEntry */ typedef struct { const char *since; const char *changes; @@ -2383,7 +2383,7 @@ struct serverCommand { dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name * (not the fullname), and the value is the serverCommand structure pointer. */ struct serverCommand *parent; - struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ + struct ValkeyModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */ }; struct serverError { @@ -2505,7 +2505,7 @@ moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name); void moduleTypeNameByID(char *name, uint64_t moduleid); const char *moduleTypeModuleName(moduleType *mt); const char *moduleNameFromCommand(struct serverCommand *cmd); -void moduleFreeContext(struct RedisModuleCtx *ctx); +void moduleFreeContext(struct ValkeyModuleCtx *ctx); void moduleCallCommandUnblockedHandler(client *c); int isModuleClientUnblocked(client *c); void unblockClientFromModule(client *c); diff --git a/src/tls.c b/src/tls.c index bb1cee14c7..ee3cd0fa3b 100644 --- a/src/tls.c +++ b/src/tls.c @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define REDISMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */ +#define VALKEYMODULE_CORE_MODULE /* A module that's part of the redis core, uses server.h too. */ #include "server.h" #include "connhelpers.h" @@ -1171,36 +1171,36 @@ int RedisRegisterConnectionTypeTLS(void) { #include "release.h" -int RedisModule_OnLoad(void *ctx, RedisModuleString **argv, int argc) { +int ValkeyModule_OnLoad(void *ctx, ValkeyModuleString **argv, int argc) { UNUSED(argv); UNUSED(argc); /* Connection modules must be part of the same build as redis. */ if (strcmp(REDIS_BUILD_ID_RAW, serverBuildIdRaw())) { serverLog(LL_NOTICE, "Connection type %s was not built together with the redis-server used.", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - if (RedisModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) - return REDISMODULE_ERR; + if (ValkeyModule_Init(ctx,"tls",1,VALKEYMODULE_APIVER_1) == VALKEYMODULE_ERR) + return VALKEYMODULE_ERR; /* Connection modules is available only bootup. */ - if ((RedisModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { + if ((ValkeyModule_GetContextFlags(ctx) & VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) { serverLog(LL_NOTICE, "Connection type %s can be loaded only during bootup", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } - RedisModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); + ValkeyModule_SetModuleOptions(ctx, VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD); if(connTypeRegister(&CT_TLS) != C_OK) - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; - return REDISMODULE_OK; + return VALKEYMODULE_OK; } -int RedisModule_OnUnload(void *arg) { +int ValkeyModule_OnUnload(void *arg) { UNUSED(arg); serverLog(LL_NOTICE, "Connection type %s can not be unloaded", CONN_TYPE_TLS); - return REDISMODULE_ERR; + return VALKEYMODULE_ERR; } #endif diff --git a/src/valkeymodule.h b/src/valkeymodule.h new file mode 100644 index 0000000000..3df3e733a1 --- /dev/null +++ b/src/valkeymodule.h @@ -0,0 +1,1698 @@ +/* + * valkeymodule.h + * + * This header file is forked from redismodule.h to reflect the new naming conventions adopted in Valkey. + * + * Key Changes: + * - Symbolic names have been changed from VALKEYMODULE_* to VALKEYMODULE_* to align with the + * new module naming convention. Developers must use these new symbolic names in their module + * implementations. + * - Terminology has been updated to be more inclusive: "slave" is now "replica", and "master" + * is now "primary". These changes are part of an effort to use more accurate and inclusive language. + * + * When developing modules for Valkey, ensure to include "valkeymodule.h". This header file contains + * the updated definitions and should be used to maintain compatibility with the changes made in Valkey. + */ + +#ifndef VALKEYMODULE_H +#define VALKEYMODULE_H + +#include +#include +#include +#include + + +typedef struct ValkeyModuleString ValkeyModuleString; +typedef struct ValkeyModuleKey ValkeyModuleKey; + +/* -------------- Defines NOT common between core and modules ------------- */ + +#if defined VALKEYMODULE_CORE +/* Things only defined for the modules core (server), not exported to modules + * that include this file. */ + +#define ValkeyModuleString robj + +#endif /* defined VALKEYMODULE_CORE */ + +#if !defined VALKEYMODULE_CORE && !defined VALKEYMODULE_CORE_MODULE +/* Things defined for modules, but not for core-modules. */ + +typedef long long mstime_t; +typedef long long ustime_t; + +#endif /* !defined VALKEYMODULE_CORE && !defined VALKEYMODULE_CORE_MODULE */ + +/* ---------------- Defines common between core and modules --------------- */ + +/* Error status return values. */ +#define VALKEYMODULE_OK 0 +#define VALKEYMODULE_ERR 1 + +/* Module Based Authentication status return values. */ +#define VALKEYMODULE_AUTH_HANDLED 0 +#define VALKEYMODULE_AUTH_NOT_HANDLED 1 + +/* API versions. */ +#define VALKEYMODULE_APIVER_1 1 + +/* Version of the ValkeyModuleTypeMethods structure. Once the ValkeyModuleTypeMethods + * structure is changed, this version number needs to be changed synchronistically. */ +#define VALKEYMODULE_TYPE_METHOD_VERSION 5 + +/* API flags and constants */ +#define VALKEYMODULE_READ (1<<0) +#define VALKEYMODULE_WRITE (1<<1) + +/* ValkeyModule_OpenKey extra flags for the 'mode' argument. + * Avoid touching the LRU/LFU of the key when opened. */ +#define VALKEYMODULE_OPEN_KEY_NOTOUCH (1<<16) +/* Don't trigger keyspace event on key misses. */ +#define VALKEYMODULE_OPEN_KEY_NONOTIFY (1<<17) +/* Don't update keyspace hits/misses counters. */ +#define VALKEYMODULE_OPEN_KEY_NOSTATS (1<<18) +/* Avoid deleting lazy expired keys. */ +#define VALKEYMODULE_OPEN_KEY_NOEXPIRE (1<<19) +/* Avoid any effects from fetching the key */ +#define VALKEYMODULE_OPEN_KEY_NOEFFECTS (1<<20) +/* Mask of all VALKEYMODULE_OPEN_KEY_* values. Any new mode should be added to this list. + * Should not be used directly by the module, use RM_GetOpenKeyModesAll instead. + * Located here so when we will add new modes we will not forget to update it. */ +#define _VALKEYMODULE_OPEN_KEY_ALL VALKEYMODULE_READ | VALKEYMODULE_WRITE | VALKEYMODULE_OPEN_KEY_NOTOUCH | VALKEYMODULE_OPEN_KEY_NONOTIFY | VALKEYMODULE_OPEN_KEY_NOSTATS | VALKEYMODULE_OPEN_KEY_NOEXPIRE | VALKEYMODULE_OPEN_KEY_NOEFFECTS + +/* List push and pop */ +#define VALKEYMODULE_LIST_HEAD 0 +#define VALKEYMODULE_LIST_TAIL 1 + +/* Key types. */ +#define VALKEYMODULE_KEYTYPE_EMPTY 0 +#define VALKEYMODULE_KEYTYPE_STRING 1 +#define VALKEYMODULE_KEYTYPE_LIST 2 +#define VALKEYMODULE_KEYTYPE_HASH 3 +#define VALKEYMODULE_KEYTYPE_SET 4 +#define VALKEYMODULE_KEYTYPE_ZSET 5 +#define VALKEYMODULE_KEYTYPE_MODULE 6 +#define VALKEYMODULE_KEYTYPE_STREAM 7 + +/* Reply types. */ +#define VALKEYMODULE_REPLY_UNKNOWN -1 +#define VALKEYMODULE_REPLY_STRING 0 +#define VALKEYMODULE_REPLY_ERROR 1 +#define VALKEYMODULE_REPLY_INTEGER 2 +#define VALKEYMODULE_REPLY_ARRAY 3 +#define VALKEYMODULE_REPLY_NULL 4 +#define VALKEYMODULE_REPLY_MAP 5 +#define VALKEYMODULE_REPLY_SET 6 +#define VALKEYMODULE_REPLY_BOOL 7 +#define VALKEYMODULE_REPLY_DOUBLE 8 +#define VALKEYMODULE_REPLY_BIG_NUMBER 9 +#define VALKEYMODULE_REPLY_VERBATIM_STRING 10 +#define VALKEYMODULE_REPLY_ATTRIBUTE 11 +#define VALKEYMODULE_REPLY_PROMISE 12 + +/* Postponed array length. */ +#define VALKEYMODULE_POSTPONED_ARRAY_LEN -1 /* Deprecated, please use VALKEYMODULE_POSTPONED_LEN */ +#define VALKEYMODULE_POSTPONED_LEN -1 + +/* Expire */ +#define VALKEYMODULE_NO_EXPIRE -1 + +/* Sorted set API flags. */ +#define VALKEYMODULE_ZADD_XX (1<<0) +#define VALKEYMODULE_ZADD_NX (1<<1) +#define VALKEYMODULE_ZADD_ADDED (1<<2) +#define VALKEYMODULE_ZADD_UPDATED (1<<3) +#define VALKEYMODULE_ZADD_NOP (1<<4) +#define VALKEYMODULE_ZADD_GT (1<<5) +#define VALKEYMODULE_ZADD_LT (1<<6) + +/* Hash API flags. */ +#define VALKEYMODULE_HASH_NONE 0 +#define VALKEYMODULE_HASH_NX (1<<0) +#define VALKEYMODULE_HASH_XX (1<<1) +#define VALKEYMODULE_HASH_CFIELDS (1<<2) +#define VALKEYMODULE_HASH_EXISTS (1<<3) +#define VALKEYMODULE_HASH_COUNT_ALL (1<<4) + +#define VALKEYMODULE_CONFIG_DEFAULT 0 /* This is the default for a module config. */ +#define VALKEYMODULE_CONFIG_IMMUTABLE (1ULL<<0) /* Can this value only be set at startup? */ +#define VALKEYMODULE_CONFIG_SENSITIVE (1ULL<<1) /* Does this value contain sensitive information */ +#define VALKEYMODULE_CONFIG_HIDDEN (1ULL<<4) /* This config is hidden in `config get ` (used for tests/debugging) */ +#define VALKEYMODULE_CONFIG_PROTECTED (1ULL<<5) /* Becomes immutable if enable-protected-configs is enabled. */ +#define VALKEYMODULE_CONFIG_DENY_LOADING (1ULL<<6) /* This config is forbidden during loading. */ + +#define VALKEYMODULE_CONFIG_MEMORY (1ULL<<7) /* Indicates if this value can be set as a memory value */ +#define VALKEYMODULE_CONFIG_BITFLAGS (1ULL<<8) /* Indicates if this value can be set as a multiple enum values */ + +/* StreamID type. */ +typedef struct ValkeyModuleStreamID { + uint64_t ms; + uint64_t seq; +} ValkeyModuleStreamID; + +/* StreamAdd() flags. */ +#define VALKEYMODULE_STREAM_ADD_AUTOID (1<<0) +/* StreamIteratorStart() flags. */ +#define VALKEYMODULE_STREAM_ITERATOR_EXCLUSIVE (1<<0) +#define VALKEYMODULE_STREAM_ITERATOR_REVERSE (1<<1) +/* StreamIteratorTrim*() flags. */ +#define VALKEYMODULE_STREAM_TRIM_APPROX (1<<0) + +/* Context Flags: Info about the current context returned by + * RM_GetContextFlags(). */ + +/* The command is running in the context of a Lua script */ +#define VALKEYMODULE_CTX_FLAGS_LUA (1<<0) +/* The command is running inside a Valkey transaction */ +#define VALKEYMODULE_CTX_FLAGS_MULTI (1<<1) +/* The instance is a primary */ +#define VALKEYMODULE_CTX_FLAGS_PRIMARY (1<<2) +/* The instance is a replic */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA (1<<3) +/* The instance is read-only (usually meaning it's a replica as well) */ +#define VALKEYMODULE_CTX_FLAGS_READONLY (1<<4) +/* The instance is running in cluster mode */ +#define VALKEYMODULE_CTX_FLAGS_CLUSTER (1<<5) +/* The instance has AOF enabled */ +#define VALKEYMODULE_CTX_FLAGS_AOF (1<<6) +/* The instance has RDB enabled */ +#define VALKEYMODULE_CTX_FLAGS_RDB (1<<7) +/* The instance has Maxmemory set */ +#define VALKEYMODULE_CTX_FLAGS_MAXMEMORY (1<<8) +/* Maxmemory is set and has an eviction policy that may delete keys */ +#define VALKEYMODULE_CTX_FLAGS_EVICT (1<<9) +/* Valkey is out of memory according to the maxmemory flag. */ +#define VALKEYMODULE_CTX_FLAGS_OOM (1<<10) +/* Less than 25% of memory available according to maxmemory. */ +#define VALKEYMODULE_CTX_FLAGS_OOM_WARNING (1<<11) +/* The command was sent over the replication link. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICATED (1<<12) +/* Valkey is currently loading either from AOF or RDB. */ +#define VALKEYMODULE_CTX_FLAGS_LOADING (1<<13) +/* The replica has no link with its primary, note that + * there is the inverse flag as well: + * + * VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE + * + * The two flags are exclusive, one or the other can be set. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_STALE (1<<14) +/* The replica is trying to connect with the primary. + * (REPL_STATE_CONNECT and REPL_STATE_CONNECTING states) */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_CONNECTING (1<<15) +/* THe replica is receiving an RDB file from its primary. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_TRANSFERRING (1<<16) +/* The replica is online, receiving updates from its primary. */ +#define VALKEYMODULE_CTX_FLAGS_REPLICA_IS_ONLINE (1<<17) +/* There is currently some background process active. */ +#define VALKEYMODULE_CTX_FLAGS_ACTIVE_CHILD (1<<18) +/* The next EXEC will fail due to dirty CAS (touched keys). */ +#define VALKEYMODULE_CTX_FLAGS_MULTI_DIRTY (1<<19) +/* Valkey is currently running inside background child process. */ +#define VALKEYMODULE_CTX_FLAGS_IS_CHILD (1<<20) +/* The current client does not allow blocking, either called from + * within multi, lua, or from another module using RM_Call */ +#define VALKEYMODULE_CTX_FLAGS_DENY_BLOCKING (1<<21) +/* The current client uses RESP3 protocol */ +#define VALKEYMODULE_CTX_FLAGS_RESP3 (1<<22) +/* Valkey is currently async loading database for diskless replication. */ +#define VALKEYMODULE_CTX_FLAGS_ASYNC_LOADING (1<<23) +/* Valkey is starting. */ +#define VALKEYMODULE_CTX_FLAGS_SERVER_STARTUP (1<<24) + +/* Next context flag, must be updated when adding new flags above! +This flag should not be used directly by the module. + * Use ValkeyModule_GetContextFlagsAll instead. */ +#define _VALKEYMODULE_CTX_FLAGS_NEXT (1<<25) + +/* Keyspace changes notification classes. Every class is associated with a + * character for configuration purposes. + * NOTE: These have to be in sync with NOTIFY_* in server.h */ +#define VALKEYMODULE_NOTIFY_KEYSPACE (1<<0) /* K */ +#define VALKEYMODULE_NOTIFY_KEYEVENT (1<<1) /* E */ +#define VALKEYMODULE_NOTIFY_GENERIC (1<<2) /* g */ +#define VALKEYMODULE_NOTIFY_STRING (1<<3) /* $ */ +#define VALKEYMODULE_NOTIFY_LIST (1<<4) /* l */ +#define VALKEYMODULE_NOTIFY_SET (1<<5) /* s */ +#define VALKEYMODULE_NOTIFY_HASH (1<<6) /* h */ +#define VALKEYMODULE_NOTIFY_ZSET (1<<7) /* z */ +#define VALKEYMODULE_NOTIFY_EXPIRED (1<<8) /* x */ +#define VALKEYMODULE_NOTIFY_EVICTED (1<<9) /* e */ +#define VALKEYMODULE_NOTIFY_STREAM (1<<10) /* t */ +#define VALKEYMODULE_NOTIFY_KEY_MISS (1<<11) /* m (Note: This one is excluded from VALKEYMODULE_NOTIFY_ALL on purpose) */ +#define VALKEYMODULE_NOTIFY_LOADED (1<<12) /* module only key space notification, indicate a key loaded from rdb */ +#define VALKEYMODULE_NOTIFY_MODULE (1<<13) /* d, module key space notification */ +#define VALKEYMODULE_NOTIFY_NEW (1<<14) /* n, new key notification */ + +/* Next notification flag, must be updated when adding new flags above! +This flag should not be used directly by the module. + * Use ValkeyModule_GetKeyspaceNotificationFlagsAll instead. */ +#define _VALKEYMODULE_NOTIFY_NEXT (1<<15) + +#define VALKEYMODULE_NOTIFY_ALL (VALKEYMODULE_NOTIFY_GENERIC | VALKEYMODULE_NOTIFY_STRING | VALKEYMODULE_NOTIFY_LIST | VALKEYMODULE_NOTIFY_SET | VALKEYMODULE_NOTIFY_HASH | VALKEYMODULE_NOTIFY_ZSET | VALKEYMODULE_NOTIFY_EXPIRED | VALKEYMODULE_NOTIFY_EVICTED | VALKEYMODULE_NOTIFY_STREAM | VALKEYMODULE_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 VALKEYMODULE_HASH_DELETE ((ValkeyModuleString*)(long)1) + +/* Error messages. */ +#define VALKEYMODULE_ERRORMSG_WRONGTYPE "WRONGTYPE Operation against a key holding the wrong kind of value" + +#define VALKEYMODULE_POSITIVE_INFINITE (1.0/0.0) +#define VALKEYMODULE_NEGATIVE_INFINITE (-1.0/0.0) + +/* Cluster API defines. */ +#define VALKEYMODULE_NODE_ID_LEN 40 +#define VALKEYMODULE_NODE_MYSELF (1<<0) +#define VALKEYMODULE_NODE_PRIMARY (1<<1) +#define VALKEYMODULE_NODE_REPLICA (1<<2) +#define VALKEYMODULE_NODE_PFAIL (1<<3) +#define VALKEYMODULE_NODE_FAIL (1<<4) +#define VALKEYMODULE_NODE_NOFAILOVER (1<<5) + +#define VALKEYMODULE_CLUSTER_FLAG_NONE 0 +#define VALKEYMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1) +#define VALKEYMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2) + +#define VALKEYMODULE_NOT_USED(V) ((void) V) + +/* Logging level strings */ +#define VALKEYMODULE_LOGLEVEL_DEBUG "debug" +#define VALKEYMODULE_LOGLEVEL_VERBOSE "verbose" +#define VALKEYMODULE_LOGLEVEL_NOTICE "notice" +#define VALKEYMODULE_LOGLEVEL_WARNING "warning" + +/* Bit flags for aux_save_triggers and the aux_load and aux_save callbacks */ +#define VALKEYMODULE_AUX_BEFORE_RDB (1<<0) +#define VALKEYMODULE_AUX_AFTER_RDB (1<<1) + +/* RM_Yield flags */ +#define VALKEYMODULE_YIELD_FLAG_NONE (1<<0) +#define VALKEYMODULE_YIELD_FLAG_CLIENTS (1<<1) + +/* RM_BlockClientOnKeysWithFlags flags */ +#define VALKEYMODULE_BLOCK_UNBLOCK_DEFAULT (0) +#define VALKEYMODULE_BLOCK_UNBLOCK_DELETED (1<<0) + +/* This type represents a timer handle, and is returned when a timer is + * 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 ValkeyModuleTimerID; + +/* CommandFilter Flags */ + +/* Do filter ValkeyModule_Call() commands initiated by module itself. */ +#define VALKEYMODULE_CMDFILTER_NOSELF (1<<0) + +/* Declare that the module can handle errors with ValkeyModule_SetModuleOptions. */ +#define VALKEYMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0) + +/* When set, Valkey will not call ValkeyModule_SignalModifiedKey(), implicitly in + * ValkeyModule_CloseKey, and the module needs to do that when manually when keys + * are modified from the user's perspective, to invalidate WATCH. */ +#define VALKEYMODULE_OPTION_NO_IMPLICIT_SIGNAL_MODIFIED (1<<1) + +/* Declare that the module can handle diskless async replication with ValkeyModule_SetModuleOptions. */ +#define VALKEYMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD (1<<2) + +/* Declare that the module want to get nested key space notifications. + * If enabled, the module is responsible to break endless loop. */ +#define VALKEYMODULE_OPTIONS_ALLOW_NESTED_KEYSPACE_NOTIFICATIONS (1<<3) + +/* Next option flag, must be updated when adding new module flags above! + * This flag should not be used directly by the module. + * Use ValkeyModule_GetModuleOptionsAll instead. */ +#define _VALKEYMODULE_OPTIONS_FLAGS_NEXT (1<<4) + +/* Definitions for ValkeyModule_SetCommandInfo. */ + +typedef enum { + VALKEYMODULE_ARG_TYPE_STRING, + VALKEYMODULE_ARG_TYPE_INTEGER, + VALKEYMODULE_ARG_TYPE_DOUBLE, + VALKEYMODULE_ARG_TYPE_KEY, /* A string, but represents a keyname */ + VALKEYMODULE_ARG_TYPE_PATTERN, + VALKEYMODULE_ARG_TYPE_UNIX_TIME, + VALKEYMODULE_ARG_TYPE_PURE_TOKEN, + VALKEYMODULE_ARG_TYPE_ONEOF, /* Must have sub-arguments */ + VALKEYMODULE_ARG_TYPE_BLOCK /* Must have sub-arguments */ +} ValkeyModuleCommandArgType; + +#define VALKEYMODULE_CMD_ARG_NONE (0) +#define VALKEYMODULE_CMD_ARG_OPTIONAL (1<<0) /* The argument is optional (like GET in SET command) */ +#define VALKEYMODULE_CMD_ARG_MULTIPLE (1<<1) /* The argument may repeat itself (like key in DEL) */ +#define VALKEYMODULE_CMD_ARG_MULTIPLE_TOKEN (1<<2) /* The argument may repeat itself, and so does its token (like `GET pattern` in SORT) */ +#define _VALKEYMODULE_CMD_ARG_NEXT (1<<3) + +typedef enum { + VALKEYMODULE_KSPEC_BS_INVALID = 0, /* Must be zero. An implicitly value of + * zero is provided when the field is + * absent in a struct literal. */ + VALKEYMODULE_KSPEC_BS_UNKNOWN, + VALKEYMODULE_KSPEC_BS_INDEX, + VALKEYMODULE_KSPEC_BS_KEYWORD +} ValkeyModuleKeySpecBeginSearchType; + +typedef enum { + VALKEYMODULE_KSPEC_FK_OMITTED = 0, /* Used when the field is absent in a + * struct literal. Don't use this value + * explicitly. */ + VALKEYMODULE_KSPEC_FK_UNKNOWN, + VALKEYMODULE_KSPEC_FK_RANGE, + VALKEYMODULE_KSPEC_FK_KEYNUM +} ValkeyModuleKeySpecFindKeysType; + +/* Key-spec flags. For details, see the documentation of + * ValkeyModule_SetCommandInfo and the key-spec flags in server.h. */ +#define VALKEYMODULE_CMD_KEY_RO (1ULL<<0) +#define VALKEYMODULE_CMD_KEY_RW (1ULL<<1) +#define VALKEYMODULE_CMD_KEY_OW (1ULL<<2) +#define VALKEYMODULE_CMD_KEY_RM (1ULL<<3) +#define VALKEYMODULE_CMD_KEY_ACCESS (1ULL<<4) +#define VALKEYMODULE_CMD_KEY_UPDATE (1ULL<<5) +#define VALKEYMODULE_CMD_KEY_INSERT (1ULL<<6) +#define VALKEYMODULE_CMD_KEY_DELETE (1ULL<<7) +#define VALKEYMODULE_CMD_KEY_NOT_KEY (1ULL<<8) +#define VALKEYMODULE_CMD_KEY_INCOMPLETE (1ULL<<9) +#define VALKEYMODULE_CMD_KEY_VARIABLE_FLAGS (1ULL<<10) + +/* Channel flags, for details see the documentation of + * ValkeyModule_ChannelAtPosWithFlags. */ +#define VALKEYMODULE_CMD_CHANNEL_PATTERN (1ULL<<0) +#define VALKEYMODULE_CMD_CHANNEL_PUBLISH (1ULL<<1) +#define VALKEYMODULE_CMD_CHANNEL_SUBSCRIBE (1ULL<<2) +#define VALKEYMODULE_CMD_CHANNEL_UNSUBSCRIBE (1ULL<<3) + +typedef struct ValkeyModuleCommandArg { + const char *name; + ValkeyModuleCommandArgType 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. */ + const char *token; /* If type is PURE_TOKEN, this is the token. */ + const char *summary; + const char *since; + int flags; /* The VALKEYMODULE_CMD_ARG_* macros. */ + const char *deprecated_since; + struct ValkeyModuleCommandArg *subargs; + const char *display_text; +} ValkeyModuleCommandArg; + +typedef struct { + const char *since; + const char *changes; +} ValkeyModuleCommandHistoryEntry; + +typedef struct { + const char *notes; + uint64_t flags; /* VALKEYMODULE_CMD_KEY_* macros. */ + ValkeyModuleKeySpecBeginSearchType begin_search_type; + union { + struct { + /* The index from which we start the search for keys */ + int pos; + } index; + struct { + /* The keyword that indicates the beginning of key args */ + const char *keyword; + /* An index in argv from which to start searching. + * Can be negative, which means start search from the end, in reverse + * (Example: -2 means to start in reverse from the penultimate arg) */ + int startfrom; + } keyword; + } bs; + ValkeyModuleKeySpecFindKeysType find_keys_type; + union { + struct { + /* Index of the last key relative to the result of the begin search + * step. Can be negative, in which case it's not relative. -1 + * indicating till the last argument, -2 one before the last and so + * on. */ + int lastkey; + /* How many args should we skip after finding a key, in order to + * find the next one. */ + int keystep; + /* If lastkey is -1, we use limit to stop the search by a factor. 0 + * and 1 mean no limit. 2 means 1/2 of the remaining args, 3 means + * 1/3, and so on. */ + int limit; + } range; + struct { + /* Index of the argument containing the number of keys to come + * relative to the result of the begin search step */ + int keynumidx; + /* Index of the fist key. (Usually it's just after keynumidx, in + * which case it should be set to keynumidx + 1.) */ + int firstkey; + /* How many args should we skip after finding a key, in order to + * find the next one, relative to the result of the begin search + * step. */ + int keystep; + } keynum; + } fk; +} ValkeyModuleCommandKeySpec; + +typedef struct { + int version; + size_t sizeof_historyentry; + size_t sizeof_keyspec; + size_t sizeof_arg; +} ValkeyModuleCommandInfoVersion; + +static const ValkeyModuleCommandInfoVersion ValkeyModule_CurrentCommandInfoVersion = { + .version = 1, + .sizeof_historyentry = sizeof(ValkeyModuleCommandHistoryEntry), + .sizeof_keyspec = sizeof(ValkeyModuleCommandKeySpec), + .sizeof_arg = sizeof(ValkeyModuleCommandArg) +}; + +#define VALKEYMODULE_COMMAND_INFO_VERSION (&ValkeyModule_CurrentCommandInfoVersion) + +typedef struct { + /* Always set version to VALKEYMODULE_COMMAND_INFO_VERSION */ + const ValkeyModuleCommandInfoVersion *version; + const char *summary; /* Summary of the command */ + const char *complexity; /* Complexity description */ + const char *since; /* Debut module version of the command */ + ValkeyModuleCommandHistoryEntry *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; + ValkeyModuleCommandKeySpec *key_specs; + ValkeyModuleCommandArg *args; +} ValkeyModuleCommandInfo; + +/* Eventloop definitions. */ +#define VALKEYMODULE_EVENTLOOP_READABLE 1 +#define VALKEYMODULE_EVENTLOOP_WRITABLE 2 +typedef void (*ValkeyModuleEventLoopFunc)(int fd, void *user_data, int mask); +typedef void (*ValkeyModuleEventLoopOneShotFunc)(void *user_data); + +/* Server events definitions. + * Those flags should not be used directly by the module, instead + * the module should use ValkeyModuleEvent_* variables. + * Note: This must be synced with moduleEventVersions */ +#define VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 +#define VALKEYMODULE_EVENT_PERSISTENCE 1 +#define VALKEYMODULE_EVENT_FLUSHDB 2 +#define VALKEYMODULE_EVENT_LOADING 3 +#define VALKEYMODULE_EVENT_CLIENT_CHANGE 4 +#define VALKEYMODULE_EVENT_SHUTDOWN 5 +#define VALKEYMODULE_EVENT_REPLICA_CHANGE 6 +#define VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE 7 +#define VALKEYMODULE_EVENT_CRON_LOOP 8 +#define VALKEYMODULE_EVENT_MODULE_CHANGE 9 +#define VALKEYMODULE_EVENT_LOADING_PROGRESS 10 +#define VALKEYMODULE_EVENT_SWAPDB 11 +#define VALKEYMODULE_EVENT_REPL_BACKUP 12 /* Not used anymore. */ +#define VALKEYMODULE_EVENT_FORK_CHILD 13 +#define VALKEYMODULE_EVENT_REPL_ASYNC_LOAD 14 +#define VALKEYMODULE_EVENT_EVENTLOOP 15 +#define VALKEYMODULE_EVENT_CONFIG 16 +#define VALKEYMODULE_EVENT_KEY 17 +#define _VALKEYMODULE_EVENT_NEXT 18 /* Next event flag, should be updated if a new event added. */ + +typedef struct ValkeyModuleEvent { + uint64_t id; /* VALKEYMODULE_EVENT_... defines. */ + uint64_t dataver; /* Version of the structure we pass as 'data'. */ +} ValkeyModuleEvent; + +struct ValkeyModuleCtx; +struct ValkeyModuleDefragCtx; +typedef void (*ValkeyModuleEventCallback)(struct ValkeyModuleCtx *ctx, ValkeyModuleEvent eid, uint64_t subevent, void *data); + +/* IMPORTANT: When adding a new version of one of below structures that contain + * event data (ValkeyModuleFlushInfoV1 for example) we have to avoid renaming the + * old ValkeyModuleEvent structure. + * For example, if we want to add ValkeyModuleFlushInfoV2, the ValkeyModuleEvent + * structures should be: + * ValkeyModuleEvent_FlushDB = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 1 + * }, + * ValkeyModuleEvent_FlushDBV2 = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 2 + * } + * and NOT: + * ValkeyModuleEvent_FlushDBV1 = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 1 + * }, + * ValkeyModuleEvent_FlushDB = { + * VALKEYMODULE_EVENT_FLUSHDB, + * 2 + * } + * The reason for that is forward-compatibility: We want that module that + * compiled with a new valkeymodule.h to be able to work with a old server, + * unless the author explicitly decided to use the newer event type. + */ +static const ValkeyModuleEvent + ValkeyModuleEvent_ReplicationRoleChanged = { + VALKEYMODULE_EVENT_REPLICATION_ROLE_CHANGED, + 1 + }, + ValkeyModuleEvent_Persistence = { + VALKEYMODULE_EVENT_PERSISTENCE, + 1 + }, + ValkeyModuleEvent_FlushDB = { + VALKEYMODULE_EVENT_FLUSHDB, + 1 + }, + ValkeyModuleEvent_Loading = { + VALKEYMODULE_EVENT_LOADING, + 1 + }, + ValkeyModuleEvent_ClientChange = { + VALKEYMODULE_EVENT_CLIENT_CHANGE, + 1 + }, + ValkeyModuleEvent_Shutdown = { + VALKEYMODULE_EVENT_SHUTDOWN, + 1 + }, + ValkeyModuleEvent_ReplicaChange = { + VALKEYMODULE_EVENT_REPLICA_CHANGE, + 1 + }, + ValkeyModuleEvent_CronLoop = { + VALKEYMODULE_EVENT_CRON_LOOP, + 1 + }, + ValkeyModuleEvent_MasterLinkChange = { + VALKEYMODULE_EVENT_PRIMARY_LINK_CHANGE, + 1 + }, + ValkeyModuleEvent_ModuleChange = { + VALKEYMODULE_EVENT_MODULE_CHANGE, + 1 + }, + ValkeyModuleEvent_LoadingProgress = { + VALKEYMODULE_EVENT_LOADING_PROGRESS, + 1 + }, + ValkeyModuleEvent_SwapDB = { + VALKEYMODULE_EVENT_SWAPDB, + 1 + }, + ValkeyModuleEvent_ReplAsyncLoad = { + VALKEYMODULE_EVENT_REPL_ASYNC_LOAD, + 1 + }, + ValkeyModuleEvent_ForkChild = { + VALKEYMODULE_EVENT_FORK_CHILD, + 1 + }, + ValkeyModuleEvent_EventLoop = { + VALKEYMODULE_EVENT_EVENTLOOP, + 1 + }, + ValkeyModuleEvent_Config = { + VALKEYMODULE_EVENT_CONFIG, + 1 + }, + ValkeyModuleEvent_Key = { + VALKEYMODULE_EVENT_KEY, + 1 + }; + +/* Those are values that are used for the 'subevent' callback argument. */ +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_RDB_START 0 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_AOF_START 1 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START 2 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_ENDED 3 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_FAILED 4 +#define VALKEYMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START 5 +#define _VALKEYMODULE_SUBEVENT_PERSISTENCE_NEXT 6 + +#define VALKEYMODULE_SUBEVENT_LOADING_RDB_START 0 +#define VALKEYMODULE_SUBEVENT_LOADING_AOF_START 1 +#define VALKEYMODULE_SUBEVENT_LOADING_REPL_START 2 +#define VALKEYMODULE_SUBEVENT_LOADING_ENDED 3 +#define VALKEYMODULE_SUBEVENT_LOADING_FAILED 4 +#define _VALKEYMODULE_SUBEVENT_LOADING_NEXT 5 + +#define VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0 +#define VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1 +#define _VALKEYMODULE_SUBEVENT_CLIENT_CHANGE_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_PRIMARY_LINK_UP 0 +#define VALKEYMODULE_SUBEVENT_PRIMARY_LINK_DOWN 1 +#define _VALKEYMODULE_SUBEVENT_PRIMARY_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE 0 +#define VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE 1 +#define _VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_NEXT 2 + +#define VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_PRIMARY 0 +#define VALKEYMODULE_EVENT_REPLROLECHANGED_NOW_REPLICA 1 +#define _VALKEYMODULE_EVENT_REPLROLECHANGED_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_FLUSHDB_START 0 +#define VALKEYMODULE_SUBEVENT_FLUSHDB_END 1 +#define _VALKEYMODULE_SUBEVENT_FLUSHDB_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_MODULE_LOADED 0 +#define VALKEYMODULE_SUBEVENT_MODULE_UNLOADED 1 +#define _VALKEYMODULE_SUBEVENT_MODULE_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_CONFIG_CHANGE 0 +#define _VALKEYMODULE_SUBEVENT_CONFIG_NEXT 1 + +#define VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_RDB 0 +#define VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_AOF 1 +#define _VALKEYMODULE_SUBEVENT_LOADING_PROGRESS_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED 0 +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED 1 +#define VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED 2 +#define _VALKEYMODULE_SUBEVENT_REPL_ASYNC_LOAD_NEXT 3 + +#define VALKEYMODULE_SUBEVENT_FORK_CHILD_BORN 0 +#define VALKEYMODULE_SUBEVENT_FORK_CHILD_DIED 1 +#define _VALKEYMODULE_SUBEVENT_FORK_CHILD_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP 0 +#define VALKEYMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP 1 +#define _VALKEYMODULE_SUBEVENT_EVENTLOOP_NEXT 2 + +#define VALKEYMODULE_SUBEVENT_KEY_DELETED 0 +#define VALKEYMODULE_SUBEVENT_KEY_EXPIRED 1 +#define VALKEYMODULE_SUBEVENT_KEY_EVICTED 2 +#define VALKEYMODULE_SUBEVENT_KEY_OVERWRITTEN 3 +#define _VALKEYMODULE_SUBEVENT_KEY_NEXT 4 + +#define _VALKEYMODULE_SUBEVENT_SHUTDOWN_NEXT 0 +#define _VALKEYMODULE_SUBEVENT_CRON_LOOP_NEXT 0 +#define _VALKEYMODULE_SUBEVENT_SWAPDB_NEXT 0 + +/* ValkeyModuleClientInfo flags. */ +#define VALKEYMODULE_CLIENTINFO_FLAG_SSL (1<<0) +#define VALKEYMODULE_CLIENTINFO_FLAG_PUBSUB (1<<1) +#define VALKEYMODULE_CLIENTINFO_FLAG_BLOCKED (1<<2) +#define VALKEYMODULE_CLIENTINFO_FLAG_TRACKING (1<<3) +#define VALKEYMODULE_CLIENTINFO_FLAG_UNIXSOCKET (1<<4) +#define VALKEYMODULE_CLIENTINFO_FLAG_MULTI (1<<5) + +/* 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 ValkeyModule_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, + * for the APIs to fill the structure. In that case, the structure 'version' + * field is initialized before passing it to the core, so that the core is + * able to cast the pointer to the appropriate structure version. In this + * way we obtain ABI compatibility. + * + * Here we'll list all the structure versions in case they evolve over time, + * however using a define, we'll make sure to use the last version as the + * public name for the module to use. */ + +#define VALKEYMODULE_CLIENTINFO_VERSION 1 +typedef struct ValkeyModuleClientInfo { + uint64_t version; /* Version of this structure for ABI compat. */ + uint64_t flags; /* VALKEYMODULE_CLIENTINFO_FLAG_* */ + uint64_t id; /* Client ID. */ + char addr[46]; /* IPv4 or IPv6 address. */ + uint16_t port; /* TCP port. */ + uint16_t db; /* Selected DB. */ +} ValkeyModuleClientInfoV1; + +#define ValkeyModuleClientInfo ValkeyModuleClientInfoV1 + +#define VALKEYMODULE_CLIENTINFO_INITIALIZER_V1 { .version = 1 } + +#define VALKEYMODULE_REPLICATIONINFO_VERSION 1 +typedef struct ValkeyModuleReplicationInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + int master; /* true if primary, false if replica */ + char *masterhost; /* primary instance hostname for NOW_REPLICA */ + int masterport; /* primary instance port for NOW_REPLICA */ + char *replid1; /* Main replication ID */ + char *replid2; /* Secondary replication ID */ + uint64_t repl1_offset; /* Main replication offset */ + uint64_t repl2_offset; /* Offset of replid2 validity */ +} ValkeyModuleReplicationInfoV1; + +#define ValkeyModuleReplicationInfo ValkeyModuleReplicationInfoV1 + +#define VALKEYMODULE_FLUSHINFO_VERSION 1 +typedef struct ValkeyModuleFlushInfo { + 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. */ +} ValkeyModuleFlushInfoV1; + +#define ValkeyModuleFlushInfo ValkeyModuleFlushInfoV1 + +#define VALKEYMODULE_MODULE_CHANGE_VERSION 1 +typedef struct ValkeyModuleModuleChange { + 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. */ +} ValkeyModuleModuleChangeV1; + +#define ValkeyModuleModuleChange ValkeyModuleModuleChangeV1 + +#define VALKEYMODULE_CONFIGCHANGE_VERSION 1 +typedef struct ValkeyModuleConfigChange { + 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 Valkey config options were changed */ + const char **config_names; /* the config names that were changed */ +} ValkeyModuleConfigChangeV1; + +#define ValkeyModuleConfigChange ValkeyModuleConfigChangeV1 + +#define VALKEYMODULE_CRON_LOOP_VERSION 1 +typedef struct ValkeyModuleCronLoopInfo { + 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. */ +} ValkeyModuleCronLoopV1; + +#define ValkeyModuleCronLoop ValkeyModuleCronLoopV1 + +#define VALKEYMODULE_LOADING_PROGRESS_VERSION 1 +typedef struct ValkeyModuleLoadingProgressInfo { + 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. */ +} ValkeyModuleLoadingProgressV1; + +#define ValkeyModuleLoadingProgress ValkeyModuleLoadingProgressV1 + +#define VALKEYMODULE_SWAPDBINFO_VERSION 1 +typedef struct ValkeyModuleSwapDbInfo { + 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 */ +} ValkeyModuleSwapDbInfoV1; + +#define ValkeyModuleSwapDbInfo ValkeyModuleSwapDbInfoV1 + +#define VALKEYMODULE_KEYINFO_VERSION 1 +typedef struct ValkeyModuleKeyInfo { + uint64_t version; /* Not used since this structure is never passed + from the module to the core right now. Here + for future compatibility. */ + ValkeyModuleKey *key; /* Opened key. */ +} ValkeyModuleKeyInfoV1; + +#define ValkeyModuleKeyInfo ValkeyModuleKeyInfoV1 + +typedef enum { + VALKEYMODULE_ACL_LOG_AUTH = 0, /* Authentication failure */ + VALKEYMODULE_ACL_LOG_CMD, /* Command authorization failure */ + VALKEYMODULE_ACL_LOG_KEY, /* Key authorization failure */ + VALKEYMODULE_ACL_LOG_CHANNEL /* Channel authorization failure */ +} ValkeyModuleACLLogEntryReason; + +/* Incomplete structures needed by both the core and modules. */ +typedef struct ValkeyModuleIO ValkeyModuleIO; +typedef struct ValkeyModuleDigest ValkeyModuleDigest; +typedef struct ValkeyModuleInfoCtx ValkeyModuleInfoCtx; +typedef struct ValkeyModuleDefragCtx ValkeyModuleDefragCtx; + +/* 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 (*ValkeyModuleInfoFunc)(ValkeyModuleInfoCtx *ctx, int for_crash_report); +typedef void (*ValkeyModuleDefragFunc)(ValkeyModuleDefragCtx *ctx); +typedef void (*ValkeyModuleUserChangedFunc) (uint64_t client_id, void *privdata); + +/* ------------------------- End of common defines ------------------------ */ + +/* ----------- The rest of the defines are only for modules ----------------- */ +#if !defined VALKEYMODULE_CORE || defined VALKEYMODULE_CORE_MODULE +/* Things defined for modules and core-modules. */ + +/* Macro definitions specific to individual compilers */ +#ifndef VALKEYMODULE_ATTR_UNUSED +# ifdef __GNUC__ +# define VALKEYMODULE_ATTR_UNUSED __attribute__((unused)) +# else +# define VALKEYMODULE_ATTR_UNUSED +# endif +#endif + +#ifndef VALKEYMODULE_ATTR_PRINTF +# ifdef __GNUC__ +# define VALKEYMODULE_ATTR_PRINTF(idx,cnt) __attribute__((format(printf,idx,cnt))) +# else +# define VALKEYMODULE_ATTR_PRINTF(idx,cnt) +# endif +#endif + +#ifndef VALKEYMODULE_ATTR_COMMON +# if defined(__GNUC__) && !(defined(__clang__) && defined(__cplusplus)) +# define VALKEYMODULE_ATTR_COMMON __attribute__((__common__)) +# else +# define VALKEYMODULE_ATTR_COMMON +# endif +#endif + +/* Incomplete structures for compiler checks but opaque access. */ +typedef struct ValkeyModuleCtx ValkeyModuleCtx; +typedef struct ValkeyModuleCommand ValkeyModuleCommand; +typedef struct ValkeyModuleCallReply ValkeyModuleCallReply; +typedef struct ValkeyModuleType ValkeyModuleType; +typedef struct ValkeyModuleBlockedClient ValkeyModuleBlockedClient; +typedef struct ValkeyModuleClusterInfo ValkeyModuleClusterInfo; +typedef struct ValkeyModuleDict ValkeyModuleDict; +typedef struct ValkeyModuleDictIter ValkeyModuleDictIter; +typedef struct ValkeyModuleCommandFilterCtx ValkeyModuleCommandFilterCtx; +typedef struct ValkeyModuleCommandFilter ValkeyModuleCommandFilter; +typedef struct ValkeyModuleServerInfoData ValkeyModuleServerInfoData; +typedef struct ValkeyModuleScanCursor ValkeyModuleScanCursor; +typedef struct ValkeyModuleUser ValkeyModuleUser; +typedef struct ValkeyModuleKeyOptCtx ValkeyModuleKeyOptCtx; +typedef struct ValkeyModuleRdbStream ValkeyModuleRdbStream; + +typedef int (*ValkeyModuleCmdFunc)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc); +typedef void (*ValkeyModuleDisconnectFunc)(ValkeyModuleCtx *ctx, ValkeyModuleBlockedClient *bc); +typedef int (*ValkeyModuleNotificationFunc)(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key); +typedef void (*ValkeyModulePostNotificationJobFunc) (ValkeyModuleCtx *ctx, void *pd); +typedef void *(*ValkeyModuleTypeLoadFunc)(ValkeyModuleIO *rdb, int encver); +typedef void (*ValkeyModuleTypeSaveFunc)(ValkeyModuleIO *rdb, void *value); +typedef int (*ValkeyModuleTypeAuxLoadFunc)(ValkeyModuleIO *rdb, int encver, int when); +typedef void (*ValkeyModuleTypeAuxSaveFunc)(ValkeyModuleIO *rdb, int when); +typedef void (*ValkeyModuleTypeRewriteFunc)(ValkeyModuleIO *aof, ValkeyModuleString *key, void *value); +typedef size_t (*ValkeyModuleTypeMemUsageFunc)(const void *value); +typedef size_t (*ValkeyModuleTypeMemUsageFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value, size_t sample_size); +typedef void (*ValkeyModuleTypeDigestFunc)(ValkeyModuleDigest *digest, void *value); +typedef void (*ValkeyModuleTypeFreeFunc)(void *value); +typedef size_t (*ValkeyModuleTypeFreeEffortFunc)(ValkeyModuleString *key, const void *value); +typedef size_t (*ValkeyModuleTypeFreeEffortFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void (*ValkeyModuleTypeUnlinkFunc)(ValkeyModuleString *key, const void *value); +typedef void (*ValkeyModuleTypeUnlinkFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef void *(*ValkeyModuleTypeCopyFunc)(ValkeyModuleString *fromkey, ValkeyModuleString *tokey, const void *value); +typedef void *(*ValkeyModuleTypeCopyFunc2)(ValkeyModuleKeyOptCtx *ctx, const void *value); +typedef int (*ValkeyModuleTypeDefragFunc)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *key, void **value); +typedef void (*ValkeyModuleClusterMessageReceiver)(ValkeyModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len); +typedef void (*ValkeyModuleTimerProc)(ValkeyModuleCtx *ctx, void *data); +typedef void (*ValkeyModuleCommandFilterFunc) (ValkeyModuleCommandFilterCtx *filter); +typedef void (*ValkeyModuleForkDoneHandler) (int exitcode, int bysignal, void *user_data); +typedef void (*ValkeyModuleScanCB)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, ValkeyModuleKey *key, void *privdata); +typedef void (*ValkeyModuleScanKeyCB)(ValkeyModuleKey *key, ValkeyModuleString *field, ValkeyModuleString *value, void *privdata); +typedef ValkeyModuleString * (*ValkeyModuleConfigGetStringFunc)(const char *name, void *privdata); +typedef long long (*ValkeyModuleConfigGetNumericFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetBoolFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigGetEnumFunc)(const char *name, void *privdata); +typedef int (*ValkeyModuleConfigSetStringFunc)(const char *name, ValkeyModuleString *val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetNumericFunc)(const char *name, long long val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetBoolFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigSetEnumFunc)(const char *name, int val, void *privdata, ValkeyModuleString **err); +typedef int (*ValkeyModuleConfigApplyFunc)(ValkeyModuleCtx *ctx, void *privdata, ValkeyModuleString **err); +typedef void (*ValkeyModuleOnUnblocked)(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply, void *private_data); +typedef int (*ValkeyModuleAuthCallback)(ValkeyModuleCtx *ctx, ValkeyModuleString *username, ValkeyModuleString *password, ValkeyModuleString **err); + +typedef struct ValkeyModuleTypeMethods { + uint64_t version; + ValkeyModuleTypeLoadFunc rdb_load; + ValkeyModuleTypeSaveFunc rdb_save; + ValkeyModuleTypeRewriteFunc aof_rewrite; + ValkeyModuleTypeMemUsageFunc mem_usage; + ValkeyModuleTypeDigestFunc digest; + ValkeyModuleTypeFreeFunc free; + ValkeyModuleTypeAuxLoadFunc aux_load; + ValkeyModuleTypeAuxSaveFunc aux_save; + int aux_save_triggers; + ValkeyModuleTypeFreeEffortFunc free_effort; + ValkeyModuleTypeUnlinkFunc unlink; + ValkeyModuleTypeCopyFunc copy; + ValkeyModuleTypeDefragFunc defrag; + ValkeyModuleTypeMemUsageFunc2 mem_usage2; + ValkeyModuleTypeFreeEffortFunc2 free_effort2; + ValkeyModuleTypeUnlinkFunc2 unlink2; + ValkeyModuleTypeCopyFunc2 copy2; + ValkeyModuleTypeAuxSaveFunc aux_save2; +} ValkeyModuleTypeMethods; + +#define VALKEYMODULE_GET_API(name) \ + ValkeyModule_GetApi("ValkeyModule_" #name, ((void **)&ValkeyModule_ ## name)) + +/* Default API declaration prefix (not 'extern' for backwards compatibility) */ +#ifndef VALKEYMODULE_API +#define VALKEYMODULE_API +#endif + +/* Default API declaration suffix (compiler attributes) */ +#ifndef VALKEYMODULE_ATTR +#define VALKEYMODULE_ATTR VALKEYMODULE_ATTR_COMMON +#endif + +VALKEYMODULE_API void * (*ValkeyModule_Alloc)(size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryAlloc)(size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_Realloc)(void *ptr, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryRealloc)(void *ptr, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Free)(void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_Calloc)(size_t nmemb, size_t size) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_TryCalloc)(size_t nmemb, size_t size) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_Strdup)(const char *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetApi)(const char *, void *) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CreateCommand)(ValkeyModuleCtx *ctx, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCommand *(*ValkeyModule_GetCommand)(ValkeyModuleCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CreateSubcommand)(ValkeyModuleCommand *parent, const char *name, ValkeyModuleCmdFunc cmdfunc, const char *strflags, int firstkey, int lastkey, int keystep) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetCommandInfo)(ValkeyModuleCommand *command, const ValkeyModuleCommandInfo *info) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetCommandACLCategories)(ValkeyModuleCommand *command, const char *ctgrsflags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AddACLCategory)(ValkeyModuleCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetModuleAttribs)(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsModuleNameBusy)(const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_WrongArity)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithLongLong)(ValkeyModuleCtx *ctx, long long ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetSelectedDb)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SelectDb)(ValkeyModuleCtx *ctx, int newid) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KeyExists)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleKey * (*ValkeyModule_OpenKey)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname, int mode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetOpenKeyModesAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_CloseKey)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KeyType)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_ValueLength)(ValkeyModuleKey *kp) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListPush)(ValkeyModuleKey *kp, int where, ValkeyModuleString *ele) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ListPop)(ValkeyModuleKey *key, int where) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ListGet)(ValkeyModuleKey *key, long index) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListSet)(ValkeyModuleKey *key, long index, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListInsert)(ValkeyModuleKey *key, long index, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ListDelete)(ValkeyModuleKey *key, long index) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_Call)(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_CallReplyProto)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeCallReply)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyType)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_CallReplyInteger)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_CallReplyDouble)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyBool)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char* (*ValkeyModule_CallReplyBigNumber)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char* (*ValkeyModule_CallReplyVerbatim)(ValkeyModuleCallReply *reply, size_t *len, const char **format) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplySetElement)(ValkeyModuleCallReply *reply, size_t idx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyMapElement)(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyAttributeElement)(ValkeyModuleCallReply *reply, size_t idx, ValkeyModuleCallReply **key, ValkeyModuleCallReply **val) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_CallReplyPromiseSetUnblockHandler)(ValkeyModuleCallReply *reply, ValkeyModuleOnUnblocked on_unblock, void *private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CallReplyPromiseAbort)(ValkeyModuleCallReply *reply, void **private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplyAttribute)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_CallReplyLength)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCallReply * (*ValkeyModule_CallReplyArrayElement)(ValkeyModuleCallReply *reply, size_t idx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateString)(ValkeyModuleCtx *ctx, const char *ptr, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromLongLong)(ValkeyModuleCtx *ctx, long long ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromULongLong)(ValkeyModuleCtx *ctx, unsigned long long ull) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromDouble)(ValkeyModuleCtx *ctx, double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromLongDouble)(ValkeyModuleCtx *ctx, long double ld, int humanfriendly) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromString)(ValkeyModuleCtx *ctx, const ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromStreamID)(ValkeyModuleCtx *ctx, const ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringPrintf)(ValkeyModuleCtx *ctx, const char *fmt, ...) VALKEYMODULE_ATTR_PRINTF(2,3) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_StringPtrLen)(const ValkeyModuleString *str, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithError)(ValkeyModuleCtx *ctx, const char *err) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithErrorFormat)(ValkeyModuleCtx *ctx, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithSimpleString)(ValkeyModuleCtx *ctx, const char *msg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithArray)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithMap)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithSet)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithAttribute)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithNullArray)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithEmptyArray)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetArrayLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetMapLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetSetLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetAttributeLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ReplySetPushLength)(ValkeyModuleCtx *ctx, long len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithStringBuffer)(ValkeyModuleCtx *ctx, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithCString)(ValkeyModuleCtx *ctx, const char *buf) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithEmptyString)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithVerbatimString)(ValkeyModuleCtx *ctx, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithVerbatimStringType)(ValkeyModuleCtx *ctx, const char *buf, size_t len, const char *ext) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithNull)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithBool)(ValkeyModuleCtx *ctx, int b) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithLongDouble)(ValkeyModuleCtx *ctx, long double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithDouble)(ValkeyModuleCtx *ctx, double d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithBigNumber)(ValkeyModuleCtx *ctx, const char *bignum, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplyWithCallReply)(ValkeyModuleCtx *ctx, ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToLongLong)(const ValkeyModuleString *str, long long *ll) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToULongLong)(const ValkeyModuleString *str, unsigned long long *ull) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToDouble)(const ValkeyModuleString *str, double *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToLongDouble)(const ValkeyModuleString *str, long double *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringToStreamID)(const ValkeyModuleString *str, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_AutoMemory)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Replicate)(ValkeyModuleCtx *ctx, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ReplicateVerbatim)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_CallReplyStringPtr)(ValkeyModuleCallReply *reply, size_t *len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CreateStringFromCallReply)(ValkeyModuleCallReply *reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DeleteKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnlinkKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringSet)(ValkeyModuleKey *key, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_StringDMA)(ValkeyModuleKey *key, size_t *len, int mode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringTruncate)(ValkeyModuleKey *key, size_t newlen) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_GetExpire)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetExpire)(ValkeyModuleKey *key, mstime_t expire) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_GetAbsExpire)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetAbsExpire)(ValkeyModuleKey *key, mstime_t expire) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ResetDataset)(int restart_aof, int async) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_DbSize)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_RandomKey)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetAdd)(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetIncrby)(ValkeyModuleKey *key, double score, ValkeyModuleString *ele, int *flagsptr, double *newscore) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetScore)(ValkeyModuleKey *key, ValkeyModuleString *ele, double *score) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRem)(ValkeyModuleKey *key, ValkeyModuleString *ele, int *deleted) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ZsetRangeStop)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetFirstInScoreRange)(ValkeyModuleKey *key, double min, double max, int minex, int maxex) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetLastInScoreRange)(ValkeyModuleKey *key, double min, double max, int minex, int maxex) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetFirstInLexRange)(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetLastInLexRange)(ValkeyModuleKey *key, ValkeyModuleString *min, ValkeyModuleString *max) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ZsetRangeCurrentElement)(ValkeyModuleKey *key, double *score) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangeNext)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangePrev)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ZsetRangeEndReached)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_HashSet)(ValkeyModuleKey *key, int flags, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_HashGet)(ValkeyModuleKey *key, int flags, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamAdd)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id, ValkeyModuleString **argv, int64_t numfields) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamDelete)(ValkeyModuleKey *key, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorStart)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *startid, ValkeyModuleStreamID *endid) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorStop)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorNextID)(ValkeyModuleKey *key, ValkeyModuleStreamID *id, long *numfields) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorNextField)(ValkeyModuleKey *key, ValkeyModuleString **field_ptr, ValkeyModuleString **value_ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StreamIteratorDelete)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_StreamTrimByLength)(ValkeyModuleKey *key, int flags, long long length) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_StreamTrimByID)(ValkeyModuleKey *key, int flags, ValkeyModuleStreamID *id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsKeysPositionRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_KeyAtPos)(ValkeyModuleCtx *ctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_KeyAtPosWithFlags)(ValkeyModuleCtx *ctx, int pos, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsChannelsPositionRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ChannelAtPosWithFlags)(ValkeyModuleCtx *ctx, int pos, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_GetClientId)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientUserNameById)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetClientInfoById)(void *ci, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientNameById)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetClientNameById)(uint64_t id, ValkeyModuleString *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_PublishMessage)(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_PublishMessageShard)(ValkeyModuleCtx *ctx, ValkeyModuleString *channel, ValkeyModuleString *message) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetContextFlags)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AvoidReplicaTraffic)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_PoolAlloc)(ValkeyModuleCtx *ctx, size_t bytes) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleType * (*ValkeyModule_CreateDataType)(ValkeyModuleCtx *ctx, const char *name, int encver, ValkeyModuleTypeMethods *typemethods) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ModuleTypeSetValue)(ValkeyModuleKey *key, ValkeyModuleType *mt, void *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ModuleTypeReplaceValue)(ValkeyModuleKey *key, ValkeyModuleType *mt, void *new_value, void **old_value) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleType * (*ValkeyModule_ModuleTypeGetType)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_ModuleTypeGetValue)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsIOError)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetModuleOptions)(ValkeyModuleCtx *ctx, int options) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SignalModifiedKey)(ValkeyModuleCtx *ctx, ValkeyModuleString *keyname) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveUnsigned)(ValkeyModuleIO *io, uint64_t value) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_LoadUnsigned)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveSigned)(ValkeyModuleIO *io, int64_t value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int64_t (*ValkeyModule_LoadSigned)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_EmitAOF)(ValkeyModuleIO *io, const char *cmdname, const char *fmt, ...) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveString)(ValkeyModuleIO *io, ValkeyModuleString *s) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveStringBuffer)(ValkeyModuleIO *io, const char *str, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_LoadString)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API char * (*ValkeyModule_LoadStringBuffer)(ValkeyModuleIO *io, size_t *lenptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveDouble)(ValkeyModuleIO *io, double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_LoadDouble)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveFloat)(ValkeyModuleIO *io, float value) VALKEYMODULE_ATTR; +VALKEYMODULE_API float (*ValkeyModule_LoadFloat)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SaveLongDouble)(ValkeyModuleIO *io, long double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API long double (*ValkeyModule_LoadLongDouble)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_LoadDataTypeFromString)(const ValkeyModuleString *str, const ValkeyModuleType *mt) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_LoadDataTypeFromStringEncver)(const ValkeyModuleString *str, const ValkeyModuleType *mt, int encver) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_SaveDataTypeToString)(ValkeyModuleCtx *ctx, void *data, const ValkeyModuleType *mt) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Log)(ValkeyModuleCtx *ctx, const char *level, const char *fmt, ...) VALKEYMODULE_ATTR VALKEYMODULE_ATTR_PRINTF(3,4); +VALKEYMODULE_API void (*ValkeyModule_LogIOError)(ValkeyModuleIO *io, const char *levelstr, const char *fmt, ...) VALKEYMODULE_ATTR VALKEYMODULE_ATTR_PRINTF(3,4); +VALKEYMODULE_API void (*ValkeyModule__Assert)(const char *estr, const char *file, int line) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_LatencyAddSample)(const char *event, mstime_t latency) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringAppendBuffer)(ValkeyModuleCtx *ctx, ValkeyModuleString *str, const char *buf, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_TrimStringAllocation)(ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RetainString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_HoldString)(ValkeyModuleCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StringCompare)(const ValkeyModuleString *a, const ValkeyModuleString *b) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetContextFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromModuleKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromModuleKey)(ValkeyModuleKey *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromIO)(ValkeyModuleIO *io) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetToDbIdFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetToKeyNameFromOptCtx)(ValkeyModuleKeyOptCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API mstime_t (*ValkeyModule_Milliseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_MonotonicMicroseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API ustime_t (*ValkeyModule_Microseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API ustime_t (*ValkeyModule_CachedMicroseconds)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestAddStringBuffer)(ValkeyModuleDigest *md, const char *ele, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestAddLongLong)(ValkeyModuleDigest *md, long long ele) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DigestEndSequence)(ValkeyModuleDigest *md) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromDigest)(ValkeyModuleDigest *dig) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromDigest)(ValkeyModuleDigest *dig) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDict * (*ValkeyModule_CreateDict)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeDict)(ValkeyModuleCtx *ctx, ValkeyModuleDict *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API uint64_t (*ValkeyModule_DictSize)(ValkeyModuleDict *d) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictSetC)(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictReplaceC)(ValkeyModuleDict *d, void *key, size_t keylen, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictSet)(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictReplace)(ValkeyModuleDict *d, ValkeyModuleString *key, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictGetC)(ValkeyModuleDict *d, void *key, size_t keylen, int *nokey) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictGet)(ValkeyModuleDict *d, ValkeyModuleString *key, int *nokey) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictDelC)(ValkeyModuleDict *d, void *key, size_t keylen, void *oldval) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictDel)(ValkeyModuleDict *d, ValkeyModuleString *key, void *oldval) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDictIter * (*ValkeyModule_DictIteratorStartC)(ValkeyModuleDict *d, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleDictIter * (*ValkeyModule_DictIteratorStart)(ValkeyModuleDict *d, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_DictIteratorStop)(ValkeyModuleDictIter *di) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictIteratorReseekC)(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictIteratorReseek)(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictNextC)(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_DictPrevC)(ValkeyModuleDictIter *di, size_t *keylen, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_DictNext)(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_DictPrev)(ValkeyModuleCtx *ctx, ValkeyModuleDictIter *di, void **dataptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictCompareC)(ValkeyModuleDictIter *di, const char *op, void *key, size_t keylen) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DictCompare)(ValkeyModuleDictIter *di, const char *op, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterInfoFunc)(ValkeyModuleCtx *ctx, ValkeyModuleInfoFunc cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RegisterAuthCallback)(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddSection)(ValkeyModuleInfoCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoBeginDictField)(ValkeyModuleInfoCtx *ctx, const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoEndDictField)(ValkeyModuleInfoCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldString)(ValkeyModuleInfoCtx *ctx, const char *field, ValkeyModuleString *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldCString)(ValkeyModuleInfoCtx *ctx, const char *field,const char *value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldDouble)(ValkeyModuleInfoCtx *ctx, const char *field, double value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldLongLong)(ValkeyModuleInfoCtx *ctx, const char *field, long long value) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_InfoAddFieldULongLong)(ValkeyModuleInfoCtx *ctx, const char *field, unsigned long long value) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleServerInfoData * (*ValkeyModule_GetServerInfo)(ValkeyModuleCtx *ctx, const char *section) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeServerInfo)(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_ServerInfoGetField)(ValkeyModuleCtx *ctx, ValkeyModuleServerInfoData *data, const char* field) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_ServerInfoGetFieldC)(ValkeyModuleServerInfoData *data, const char* field) VALKEYMODULE_ATTR; +VALKEYMODULE_API long long (*ValkeyModule_ServerInfoGetFieldSigned)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_ServerInfoGetFieldUnsigned)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API double (*ValkeyModule_ServerInfoGetFieldDouble)(ValkeyModuleServerInfoData *data, const char* field, int *out_err) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SubscribeToServerEvent)(ValkeyModuleCtx *ctx, ValkeyModuleEvent event, ValkeyModuleEventCallback callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetLRU)(ValkeyModuleKey *key, mstime_t lru_idle) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetLRU)(ValkeyModuleKey *key, mstime_t *lru_idle) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetLFU)(ValkeyModuleKey *key, long long lfu_freq) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetLFU)(ValkeyModuleKey *key, long long *lfu_freq) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnKeys)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnKeysWithFlags)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms, ValkeyModuleString **keys, int numkeys, void *privdata, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SignalKeyAsReady)(ValkeyModuleCtx *ctx, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetBlockedClientReadyKey)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleScanCursor * (*ValkeyModule_ScanCursorCreate)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ScanCursorRestart)(ValkeyModuleScanCursor *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ScanCursorDestroy)(ValkeyModuleScanCursor *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Scan)(ValkeyModuleCtx *ctx, ValkeyModuleScanCursor *cursor, ValkeyModuleScanCB fn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ScanKey)(ValkeyModuleKey *key, ValkeyModuleScanCursor *cursor, ValkeyModuleScanKeyCB fn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetContextFlagsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetModuleOptionsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetKeyspaceNotificationFlagsAll)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsSubEventSupported)(ValkeyModuleEvent event, uint64_t subevent) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetServerVersion)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetTypeMethodVersion)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_Yield)(ValkeyModuleCtx *ctx, int flags, const char *busy_reply) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClient)(ValkeyModuleCtx *ctx, ValkeyModuleCmdFunc reply_callback, ValkeyModuleCmdFunc timeout_callback, void (*free_privdata)(ValkeyModuleCtx*,void*), long long timeout_ms) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_BlockClientGetPrivateData)(ValkeyModuleBlockedClient *blocked_client) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_BlockClientSetPrivateData)(ValkeyModuleBlockedClient *blocked_client, void *private_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_BlockClientOnAuth)(ValkeyModuleCtx *ctx, ValkeyModuleAuthCallback reply_callback, void (*free_privdata)(ValkeyModuleCtx*,void*)) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnblockClient)(ValkeyModuleBlockedClient *bc, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsBlockedReplyRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_IsBlockedTimeoutRequest)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_GetBlockedClientPrivateData)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleBlockedClient * (*ValkeyModule_GetBlockedClientHandle)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AbortBlock)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientMeasureTimeStart)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientMeasureTimeEnd)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetThreadSafeContext)(ValkeyModuleBlockedClient *bc) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCtx * (*ValkeyModule_GetDetachedThreadSafeContext)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeThreadSafeContext)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ThreadSafeContextLock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ThreadSafeContextTryLock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ThreadSafeContextUnlock)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SubscribeToKeyspaceEvents)(ValkeyModuleCtx *ctx, int types, ValkeyModuleNotificationFunc cb) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AddPostNotificationJob)(ValkeyModuleCtx *ctx, ValkeyModulePostNotificationJobFunc callback, void *pd, void (*free_pd)(void*)) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_NotifyKeyspaceEvent)(ValkeyModuleCtx *ctx, int type, const char *event, ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetNotifyKeyspaceEvents)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_BlockedClientDisconnected)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RegisterClusterMessageReceiver)(ValkeyModuleCtx *ctx, uint8_t type, ValkeyModuleClusterMessageReceiver callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SendClusterMessage)(ValkeyModuleCtx *ctx, const char *target_id, uint8_t type, const char *msg, uint32_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetClusterNodeInfo)(ValkeyModuleCtx *ctx, const char *id, char *ip, char *master_id, int *port, int *flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API char ** (*ValkeyModule_GetClusterNodesList)(ValkeyModuleCtx *ctx, size_t *numnodes) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeClusterNodesList)(char **ids) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleTimerID (*ValkeyModule_CreateTimer)(ValkeyModuleCtx *ctx, mstime_t period, ValkeyModuleTimerProc callback, void *data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_StopTimer)(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, void **data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetTimerInfo)(ValkeyModuleCtx *ctx, ValkeyModuleTimerID id, uint64_t *remaining, void **data) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char * (*ValkeyModule_GetMyClusterID)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_GetClusterSize)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_GetRandomBytes)(unsigned char *dst, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_GetRandomHexChars)(char *dst, size_t len) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetDisconnectCallback)(ValkeyModuleBlockedClient *bc, ValkeyModuleDisconnectFunc callback) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetClusterFlags)(ValkeyModuleCtx *ctx, uint64_t flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned int (*ValkeyModule_ClusterKeySlot)(ValkeyModuleString *key) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char *(*ValkeyModule_ClusterCanonicalKeyNameInSlot)(unsigned int slot) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ExportSharedAPI)(ValkeyModuleCtx *ctx, const char *apiname, void *func) VALKEYMODULE_ATTR; +VALKEYMODULE_API void * (*ValkeyModule_GetSharedAPI)(ValkeyModuleCtx *ctx, const char *apiname) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleCommandFilter * (*ValkeyModule_RegisterCommandFilter)(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilterFunc cb, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_UnregisterCommandFilter)(ValkeyModuleCtx *ctx, ValkeyModuleCommandFilter *filter) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgsCount)(ValkeyModuleCommandFilterCtx *fctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_CommandFilterArgGet)(ValkeyModuleCommandFilterCtx *fctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgInsert)(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgReplace)(ValkeyModuleCommandFilterCtx *fctx, int pos, ValkeyModuleString *arg) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_CommandFilterArgDelete)(ValkeyModuleCommandFilterCtx *fctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API unsigned long long (*ValkeyModule_CommandFilterGetClientId)(ValkeyModuleCommandFilterCtx *fctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_Fork)(ValkeyModuleForkDoneHandler cb, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SendChildHeartbeat)(double progress) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ExitFromChild)(int retcode) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_KillForkChild)(int child_pid) VALKEYMODULE_ATTR; +VALKEYMODULE_API float (*ValkeyModule_GetUsedMemoryRatio)(void) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSize)(void* ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocUsableSize)(void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSizeString)(ValkeyModuleString* str) VALKEYMODULE_ATTR; +VALKEYMODULE_API size_t (*ValkeyModule_MallocSizeDict)(ValkeyModuleDict* dict) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleUser * (*ValkeyModule_CreateModuleUser)(const char *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_FreeModuleUser)(ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_SetContextUser)(ValkeyModuleCtx *ctx, const ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetModuleUserACL)(ValkeyModuleUser *user, const char* acl) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_SetModuleUserACLString)(ValkeyModuleCtx * ctx, ValkeyModuleUser *user, const char* acl, ValkeyModuleString **error) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetModuleUserACLString)(ValkeyModuleUser *user) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetCurrentUserName)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleUser * (*ValkeyModule_GetModuleUserFromUserName)(ValkeyModuleString *name) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckCommandPermissions)(ValkeyModuleUser *user, ValkeyModuleString **argv, int argc) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckKeyPermissions)(ValkeyModuleUser *user, ValkeyModuleString *key, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_ACLCheckChannelPermissions)(ValkeyModuleUser *user, ValkeyModuleString *ch, int literal) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ACLAddLogEntry)(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_ACLAddLogEntryByUserName)(ValkeyModuleCtx *ctx, ValkeyModuleString *user, ValkeyModuleString *object, ValkeyModuleACLLogEntryReason reason) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AuthenticateClientWithACLUser)(ValkeyModuleCtx *ctx, const char *name, size_t len, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_AuthenticateClientWithUser)(ValkeyModuleCtx *ctx, ValkeyModuleUser *user, ValkeyModuleUserChangedFunc callback, void *privdata, uint64_t *client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DeauthenticateAndCloseClient)(ValkeyModuleCtx *ctx, uint64_t client_id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RedactClientCommandArgument)(ValkeyModuleCtx *ctx, int pos) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString * (*ValkeyModule_GetClientCertificate)(ValkeyModuleCtx *ctx, uint64_t id) VALKEYMODULE_ATTR; +VALKEYMODULE_API int *(*ValkeyModule_GetCommandKeys)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys) VALKEYMODULE_ATTR; +VALKEYMODULE_API int *(*ValkeyModule_GetCommandKeysWithFlags)(ValkeyModuleCtx *ctx, ValkeyModuleString **argv, int argc, int *num_keys, int **out_flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API const char *(*ValkeyModule_GetCurrentCommandName)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterDefragFunc)(ValkeyModuleCtx *ctx, ValkeyModuleDefragFunc func) VALKEYMODULE_ATTR; +VALKEYMODULE_API void *(*ValkeyModule_DefragAlloc)(ValkeyModuleDefragCtx *ctx, void *ptr) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleString *(*ValkeyModule_DefragModuleString)(ValkeyModuleDefragCtx *ctx, ValkeyModuleString *str) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragShouldStop)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragCursorSet)(ValkeyModuleDefragCtx *ctx, unsigned long cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_DefragCursorGet)(ValkeyModuleDefragCtx *ctx, unsigned long *cursor) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_GetDbIdFromDefragCtx)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API const ValkeyModuleString * (*ValkeyModule_GetKeyNameFromDefragCtx)(ValkeyModuleDefragCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopAdd)(int fd, int mask, ValkeyModuleEventLoopFunc func, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopDel)(int fd, int mask) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_EventLoopAddOneShot)(ValkeyModuleEventLoopOneShotFunc func, void *user_data) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterBoolConfig)(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, ValkeyModuleConfigGetBoolFunc getfn, ValkeyModuleConfigSetBoolFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterNumericConfig)(ValkeyModuleCtx *ctx, const char *name, long long default_val, unsigned int flags, long long min, long long max, ValkeyModuleConfigGetNumericFunc getfn, ValkeyModuleConfigSetNumericFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterStringConfig)(ValkeyModuleCtx *ctx, const char *name, const char *default_val, unsigned int flags, ValkeyModuleConfigGetStringFunc getfn, ValkeyModuleConfigSetStringFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RegisterEnumConfig)(ValkeyModuleCtx *ctx, const char *name, int default_val, unsigned int flags, const char **enum_values, const int *int_values, int num_enum_vals, ValkeyModuleConfigGetEnumFunc getfn, ValkeyModuleConfigSetEnumFunc setfn, ValkeyModuleConfigApplyFunc applyfn, void *privdata) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_LoadConfigs)(ValkeyModuleCtx *ctx) VALKEYMODULE_ATTR; +VALKEYMODULE_API ValkeyModuleRdbStream *(*ValkeyModule_RdbStreamCreateFromFile)(const char *filename) VALKEYMODULE_ATTR; +VALKEYMODULE_API void (*ValkeyModule_RdbStreamFree)(ValkeyModuleRdbStream *stream) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RdbLoad)(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) VALKEYMODULE_ATTR; +VALKEYMODULE_API int (*ValkeyModule_RdbSave)(ValkeyModuleCtx *ctx, ValkeyModuleRdbStream *stream, int flags) VALKEYMODULE_ATTR; + +#define ValkeyModule_IsAOFClient(id) ((id) == UINT64_MAX) + +/* This is included inline inside each Valkey module. */ +static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) VALKEYMODULE_ATTR_UNUSED; +static int ValkeyModule_Init(ValkeyModuleCtx *ctx, const char *name, int ver, int apiver) { + void *getapifuncptr = ((void**)ctx)[0]; + ValkeyModule_GetApi = (int (*)(const char *, void *)) (unsigned long)getapifuncptr; + VALKEYMODULE_GET_API(Alloc); + VALKEYMODULE_GET_API(TryAlloc); + VALKEYMODULE_GET_API(Calloc); + VALKEYMODULE_GET_API(TryCalloc); + VALKEYMODULE_GET_API(Free); + VALKEYMODULE_GET_API(Realloc); + VALKEYMODULE_GET_API(TryRealloc); + VALKEYMODULE_GET_API(Strdup); + VALKEYMODULE_GET_API(CreateCommand); + VALKEYMODULE_GET_API(GetCommand); + VALKEYMODULE_GET_API(CreateSubcommand); + VALKEYMODULE_GET_API(SetCommandInfo); + VALKEYMODULE_GET_API(SetCommandACLCategories); + VALKEYMODULE_GET_API(AddACLCategory); + VALKEYMODULE_GET_API(SetModuleAttribs); + VALKEYMODULE_GET_API(IsModuleNameBusy); + VALKEYMODULE_GET_API(WrongArity); + VALKEYMODULE_GET_API(ReplyWithLongLong); + VALKEYMODULE_GET_API(ReplyWithError); + VALKEYMODULE_GET_API(ReplyWithErrorFormat); + VALKEYMODULE_GET_API(ReplyWithSimpleString); + VALKEYMODULE_GET_API(ReplyWithArray); + VALKEYMODULE_GET_API(ReplyWithMap); + VALKEYMODULE_GET_API(ReplyWithSet); + VALKEYMODULE_GET_API(ReplyWithAttribute); + VALKEYMODULE_GET_API(ReplyWithNullArray); + VALKEYMODULE_GET_API(ReplyWithEmptyArray); + VALKEYMODULE_GET_API(ReplySetArrayLength); + VALKEYMODULE_GET_API(ReplySetMapLength); + VALKEYMODULE_GET_API(ReplySetSetLength); + VALKEYMODULE_GET_API(ReplySetAttributeLength); + VALKEYMODULE_GET_API(ReplySetPushLength); + VALKEYMODULE_GET_API(ReplyWithStringBuffer); + VALKEYMODULE_GET_API(ReplyWithCString); + VALKEYMODULE_GET_API(ReplyWithString); + VALKEYMODULE_GET_API(ReplyWithEmptyString); + VALKEYMODULE_GET_API(ReplyWithVerbatimString); + VALKEYMODULE_GET_API(ReplyWithVerbatimStringType); + VALKEYMODULE_GET_API(ReplyWithNull); + VALKEYMODULE_GET_API(ReplyWithBool); + VALKEYMODULE_GET_API(ReplyWithCallReply); + VALKEYMODULE_GET_API(ReplyWithDouble); + VALKEYMODULE_GET_API(ReplyWithBigNumber); + VALKEYMODULE_GET_API(ReplyWithLongDouble); + VALKEYMODULE_GET_API(GetSelectedDb); + VALKEYMODULE_GET_API(SelectDb); + VALKEYMODULE_GET_API(KeyExists); + VALKEYMODULE_GET_API(OpenKey); + VALKEYMODULE_GET_API(GetOpenKeyModesAll); + VALKEYMODULE_GET_API(CloseKey); + VALKEYMODULE_GET_API(KeyType); + VALKEYMODULE_GET_API(ValueLength); + VALKEYMODULE_GET_API(ListPush); + VALKEYMODULE_GET_API(ListPop); + VALKEYMODULE_GET_API(ListGet); + VALKEYMODULE_GET_API(ListSet); + VALKEYMODULE_GET_API(ListInsert); + VALKEYMODULE_GET_API(ListDelete); + VALKEYMODULE_GET_API(StringToLongLong); + VALKEYMODULE_GET_API(StringToULongLong); + VALKEYMODULE_GET_API(StringToDouble); + VALKEYMODULE_GET_API(StringToLongDouble); + VALKEYMODULE_GET_API(StringToStreamID); + VALKEYMODULE_GET_API(Call); + VALKEYMODULE_GET_API(CallReplyProto); + VALKEYMODULE_GET_API(FreeCallReply); + VALKEYMODULE_GET_API(CallReplyInteger); + VALKEYMODULE_GET_API(CallReplyDouble); + VALKEYMODULE_GET_API(CallReplyBool); + VALKEYMODULE_GET_API(CallReplyBigNumber); + VALKEYMODULE_GET_API(CallReplyVerbatim); + VALKEYMODULE_GET_API(CallReplySetElement); + VALKEYMODULE_GET_API(CallReplyMapElement); + VALKEYMODULE_GET_API(CallReplyAttributeElement); + VALKEYMODULE_GET_API(CallReplyPromiseSetUnblockHandler); + VALKEYMODULE_GET_API(CallReplyPromiseAbort); + VALKEYMODULE_GET_API(CallReplyAttribute); + VALKEYMODULE_GET_API(CallReplyType); + VALKEYMODULE_GET_API(CallReplyLength); + VALKEYMODULE_GET_API(CallReplyArrayElement); + VALKEYMODULE_GET_API(CallReplyStringPtr); + VALKEYMODULE_GET_API(CreateStringFromCallReply); + VALKEYMODULE_GET_API(CreateString); + VALKEYMODULE_GET_API(CreateStringFromLongLong); + VALKEYMODULE_GET_API(CreateStringFromULongLong); + VALKEYMODULE_GET_API(CreateStringFromDouble); + VALKEYMODULE_GET_API(CreateStringFromLongDouble); + VALKEYMODULE_GET_API(CreateStringFromString); + VALKEYMODULE_GET_API(CreateStringFromStreamID); + VALKEYMODULE_GET_API(CreateStringPrintf); + VALKEYMODULE_GET_API(FreeString); + VALKEYMODULE_GET_API(StringPtrLen); + VALKEYMODULE_GET_API(AutoMemory); + VALKEYMODULE_GET_API(Replicate); + VALKEYMODULE_GET_API(ReplicateVerbatim); + VALKEYMODULE_GET_API(DeleteKey); + VALKEYMODULE_GET_API(UnlinkKey); + VALKEYMODULE_GET_API(StringSet); + VALKEYMODULE_GET_API(StringDMA); + VALKEYMODULE_GET_API(StringTruncate); + VALKEYMODULE_GET_API(GetExpire); + VALKEYMODULE_GET_API(SetExpire); + VALKEYMODULE_GET_API(GetAbsExpire); + VALKEYMODULE_GET_API(SetAbsExpire); + VALKEYMODULE_GET_API(ResetDataset); + VALKEYMODULE_GET_API(DbSize); + VALKEYMODULE_GET_API(RandomKey); + VALKEYMODULE_GET_API(ZsetAdd); + VALKEYMODULE_GET_API(ZsetIncrby); + VALKEYMODULE_GET_API(ZsetScore); + VALKEYMODULE_GET_API(ZsetRem); + VALKEYMODULE_GET_API(ZsetRangeStop); + VALKEYMODULE_GET_API(ZsetFirstInScoreRange); + VALKEYMODULE_GET_API(ZsetLastInScoreRange); + VALKEYMODULE_GET_API(ZsetFirstInLexRange); + VALKEYMODULE_GET_API(ZsetLastInLexRange); + VALKEYMODULE_GET_API(ZsetRangeCurrentElement); + VALKEYMODULE_GET_API(ZsetRangeNext); + VALKEYMODULE_GET_API(ZsetRangePrev); + VALKEYMODULE_GET_API(ZsetRangeEndReached); + VALKEYMODULE_GET_API(HashSet); + VALKEYMODULE_GET_API(HashGet); + VALKEYMODULE_GET_API(StreamAdd); + VALKEYMODULE_GET_API(StreamDelete); + VALKEYMODULE_GET_API(StreamIteratorStart); + VALKEYMODULE_GET_API(StreamIteratorStop); + VALKEYMODULE_GET_API(StreamIteratorNextID); + VALKEYMODULE_GET_API(StreamIteratorNextField); + VALKEYMODULE_GET_API(StreamIteratorDelete); + VALKEYMODULE_GET_API(StreamTrimByLength); + VALKEYMODULE_GET_API(StreamTrimByID); + VALKEYMODULE_GET_API(IsKeysPositionRequest); + VALKEYMODULE_GET_API(KeyAtPos); + VALKEYMODULE_GET_API(KeyAtPosWithFlags); + VALKEYMODULE_GET_API(IsChannelsPositionRequest); + VALKEYMODULE_GET_API(ChannelAtPosWithFlags); + VALKEYMODULE_GET_API(GetClientId); + VALKEYMODULE_GET_API(GetClientUserNameById); + VALKEYMODULE_GET_API(GetContextFlags); + VALKEYMODULE_GET_API(AvoidReplicaTraffic); + VALKEYMODULE_GET_API(PoolAlloc); + VALKEYMODULE_GET_API(CreateDataType); + VALKEYMODULE_GET_API(ModuleTypeSetValue); + VALKEYMODULE_GET_API(ModuleTypeReplaceValue); + VALKEYMODULE_GET_API(ModuleTypeGetType); + VALKEYMODULE_GET_API(ModuleTypeGetValue); + VALKEYMODULE_GET_API(IsIOError); + VALKEYMODULE_GET_API(SetModuleOptions); + VALKEYMODULE_GET_API(SignalModifiedKey); + VALKEYMODULE_GET_API(SaveUnsigned); + VALKEYMODULE_GET_API(LoadUnsigned); + VALKEYMODULE_GET_API(SaveSigned); + VALKEYMODULE_GET_API(LoadSigned); + VALKEYMODULE_GET_API(SaveString); + VALKEYMODULE_GET_API(SaveStringBuffer); + VALKEYMODULE_GET_API(LoadString); + VALKEYMODULE_GET_API(LoadStringBuffer); + VALKEYMODULE_GET_API(SaveDouble); + VALKEYMODULE_GET_API(LoadDouble); + VALKEYMODULE_GET_API(SaveFloat); + VALKEYMODULE_GET_API(LoadFloat); + VALKEYMODULE_GET_API(SaveLongDouble); + VALKEYMODULE_GET_API(LoadLongDouble); + VALKEYMODULE_GET_API(SaveDataTypeToString); + VALKEYMODULE_GET_API(LoadDataTypeFromString); + VALKEYMODULE_GET_API(LoadDataTypeFromStringEncver); + VALKEYMODULE_GET_API(EmitAOF); + VALKEYMODULE_GET_API(Log); + VALKEYMODULE_GET_API(LogIOError); + VALKEYMODULE_GET_API(_Assert); + VALKEYMODULE_GET_API(LatencyAddSample); + VALKEYMODULE_GET_API(StringAppendBuffer); + VALKEYMODULE_GET_API(TrimStringAllocation); + VALKEYMODULE_GET_API(RetainString); + VALKEYMODULE_GET_API(HoldString); + VALKEYMODULE_GET_API(StringCompare); + VALKEYMODULE_GET_API(GetContextFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromModuleKey); + VALKEYMODULE_GET_API(GetDbIdFromModuleKey); + VALKEYMODULE_GET_API(GetDbIdFromIO); + VALKEYMODULE_GET_API(GetKeyNameFromOptCtx); + VALKEYMODULE_GET_API(GetToKeyNameFromOptCtx); + VALKEYMODULE_GET_API(GetDbIdFromOptCtx); + VALKEYMODULE_GET_API(GetToDbIdFromOptCtx); + VALKEYMODULE_GET_API(Milliseconds); + VALKEYMODULE_GET_API(MonotonicMicroseconds); + VALKEYMODULE_GET_API(Microseconds); + VALKEYMODULE_GET_API(CachedMicroseconds); + VALKEYMODULE_GET_API(DigestAddStringBuffer); + VALKEYMODULE_GET_API(DigestAddLongLong); + VALKEYMODULE_GET_API(DigestEndSequence); + VALKEYMODULE_GET_API(GetKeyNameFromDigest); + VALKEYMODULE_GET_API(GetDbIdFromDigest); + VALKEYMODULE_GET_API(CreateDict); + VALKEYMODULE_GET_API(FreeDict); + VALKEYMODULE_GET_API(DictSize); + VALKEYMODULE_GET_API(DictSetC); + VALKEYMODULE_GET_API(DictReplaceC); + VALKEYMODULE_GET_API(DictSet); + VALKEYMODULE_GET_API(DictReplace); + VALKEYMODULE_GET_API(DictGetC); + VALKEYMODULE_GET_API(DictGet); + VALKEYMODULE_GET_API(DictDelC); + VALKEYMODULE_GET_API(DictDel); + VALKEYMODULE_GET_API(DictIteratorStartC); + VALKEYMODULE_GET_API(DictIteratorStart); + VALKEYMODULE_GET_API(DictIteratorStop); + VALKEYMODULE_GET_API(DictIteratorReseekC); + VALKEYMODULE_GET_API(DictIteratorReseek); + VALKEYMODULE_GET_API(DictNextC); + VALKEYMODULE_GET_API(DictPrevC); + VALKEYMODULE_GET_API(DictNext); + VALKEYMODULE_GET_API(DictPrev); + VALKEYMODULE_GET_API(DictCompare); + VALKEYMODULE_GET_API(DictCompareC); + VALKEYMODULE_GET_API(RegisterInfoFunc); + VALKEYMODULE_GET_API(RegisterAuthCallback); + VALKEYMODULE_GET_API(InfoAddSection); + VALKEYMODULE_GET_API(InfoBeginDictField); + VALKEYMODULE_GET_API(InfoEndDictField); + VALKEYMODULE_GET_API(InfoAddFieldString); + VALKEYMODULE_GET_API(InfoAddFieldCString); + VALKEYMODULE_GET_API(InfoAddFieldDouble); + VALKEYMODULE_GET_API(InfoAddFieldLongLong); + VALKEYMODULE_GET_API(InfoAddFieldULongLong); + VALKEYMODULE_GET_API(GetServerInfo); + VALKEYMODULE_GET_API(FreeServerInfo); + VALKEYMODULE_GET_API(ServerInfoGetField); + VALKEYMODULE_GET_API(ServerInfoGetFieldC); + VALKEYMODULE_GET_API(ServerInfoGetFieldSigned); + VALKEYMODULE_GET_API(ServerInfoGetFieldUnsigned); + VALKEYMODULE_GET_API(ServerInfoGetFieldDouble); + VALKEYMODULE_GET_API(GetClientInfoById); + VALKEYMODULE_GET_API(GetClientNameById); + VALKEYMODULE_GET_API(SetClientNameById); + VALKEYMODULE_GET_API(PublishMessage); + VALKEYMODULE_GET_API(PublishMessageShard); + VALKEYMODULE_GET_API(SubscribeToServerEvent); + VALKEYMODULE_GET_API(SetLRU); + VALKEYMODULE_GET_API(GetLRU); + VALKEYMODULE_GET_API(SetLFU); + VALKEYMODULE_GET_API(GetLFU); + VALKEYMODULE_GET_API(BlockClientOnKeys); + VALKEYMODULE_GET_API(BlockClientOnKeysWithFlags); + VALKEYMODULE_GET_API(SignalKeyAsReady); + VALKEYMODULE_GET_API(GetBlockedClientReadyKey); + VALKEYMODULE_GET_API(ScanCursorCreate); + VALKEYMODULE_GET_API(ScanCursorRestart); + VALKEYMODULE_GET_API(ScanCursorDestroy); + VALKEYMODULE_GET_API(Scan); + VALKEYMODULE_GET_API(ScanKey); + VALKEYMODULE_GET_API(GetContextFlagsAll); + VALKEYMODULE_GET_API(GetModuleOptionsAll); + VALKEYMODULE_GET_API(GetKeyspaceNotificationFlagsAll); + VALKEYMODULE_GET_API(IsSubEventSupported); + VALKEYMODULE_GET_API(GetServerVersion); + VALKEYMODULE_GET_API(GetTypeMethodVersion); + VALKEYMODULE_GET_API(Yield); + VALKEYMODULE_GET_API(GetThreadSafeContext); + VALKEYMODULE_GET_API(GetDetachedThreadSafeContext); + VALKEYMODULE_GET_API(FreeThreadSafeContext); + VALKEYMODULE_GET_API(ThreadSafeContextLock); + VALKEYMODULE_GET_API(ThreadSafeContextTryLock); + VALKEYMODULE_GET_API(ThreadSafeContextUnlock); + VALKEYMODULE_GET_API(BlockClient); + VALKEYMODULE_GET_API(BlockClientGetPrivateData); + VALKEYMODULE_GET_API(BlockClientSetPrivateData); + VALKEYMODULE_GET_API(BlockClientOnAuth); + VALKEYMODULE_GET_API(UnblockClient); + VALKEYMODULE_GET_API(IsBlockedReplyRequest); + VALKEYMODULE_GET_API(IsBlockedTimeoutRequest); + VALKEYMODULE_GET_API(GetBlockedClientPrivateData); + VALKEYMODULE_GET_API(GetBlockedClientHandle); + VALKEYMODULE_GET_API(AbortBlock); + VALKEYMODULE_GET_API(BlockedClientMeasureTimeStart); + VALKEYMODULE_GET_API(BlockedClientMeasureTimeEnd); + VALKEYMODULE_GET_API(SetDisconnectCallback); + VALKEYMODULE_GET_API(SubscribeToKeyspaceEvents); + VALKEYMODULE_GET_API(AddPostNotificationJob); + VALKEYMODULE_GET_API(NotifyKeyspaceEvent); + VALKEYMODULE_GET_API(GetNotifyKeyspaceEvents); + VALKEYMODULE_GET_API(BlockedClientDisconnected); + VALKEYMODULE_GET_API(RegisterClusterMessageReceiver); + VALKEYMODULE_GET_API(SendClusterMessage); + VALKEYMODULE_GET_API(GetClusterNodeInfo); + VALKEYMODULE_GET_API(GetClusterNodesList); + VALKEYMODULE_GET_API(FreeClusterNodesList); + VALKEYMODULE_GET_API(CreateTimer); + VALKEYMODULE_GET_API(StopTimer); + VALKEYMODULE_GET_API(GetTimerInfo); + VALKEYMODULE_GET_API(GetMyClusterID); + VALKEYMODULE_GET_API(GetClusterSize); + VALKEYMODULE_GET_API(GetRandomBytes); + VALKEYMODULE_GET_API(GetRandomHexChars); + VALKEYMODULE_GET_API(SetClusterFlags); + VALKEYMODULE_GET_API(ClusterKeySlot); + VALKEYMODULE_GET_API(ClusterCanonicalKeyNameInSlot); + VALKEYMODULE_GET_API(ExportSharedAPI); + VALKEYMODULE_GET_API(GetSharedAPI); + VALKEYMODULE_GET_API(RegisterCommandFilter); + VALKEYMODULE_GET_API(UnregisterCommandFilter); + VALKEYMODULE_GET_API(CommandFilterArgsCount); + VALKEYMODULE_GET_API(CommandFilterArgGet); + VALKEYMODULE_GET_API(CommandFilterArgInsert); + VALKEYMODULE_GET_API(CommandFilterArgReplace); + VALKEYMODULE_GET_API(CommandFilterArgDelete); + VALKEYMODULE_GET_API(CommandFilterGetClientId); + VALKEYMODULE_GET_API(Fork); + VALKEYMODULE_GET_API(SendChildHeartbeat); + VALKEYMODULE_GET_API(ExitFromChild); + VALKEYMODULE_GET_API(KillForkChild); + VALKEYMODULE_GET_API(GetUsedMemoryRatio); + VALKEYMODULE_GET_API(MallocSize); + VALKEYMODULE_GET_API(MallocUsableSize); + VALKEYMODULE_GET_API(MallocSizeString); + VALKEYMODULE_GET_API(MallocSizeDict); + VALKEYMODULE_GET_API(CreateModuleUser); + VALKEYMODULE_GET_API(FreeModuleUser); + VALKEYMODULE_GET_API(SetContextUser); + VALKEYMODULE_GET_API(SetModuleUserACL); + VALKEYMODULE_GET_API(SetModuleUserACLString); + VALKEYMODULE_GET_API(GetModuleUserACLString); + VALKEYMODULE_GET_API(GetCurrentUserName); + VALKEYMODULE_GET_API(GetModuleUserFromUserName); + VALKEYMODULE_GET_API(ACLCheckCommandPermissions); + VALKEYMODULE_GET_API(ACLCheckKeyPermissions); + VALKEYMODULE_GET_API(ACLCheckChannelPermissions); + VALKEYMODULE_GET_API(ACLAddLogEntry); + VALKEYMODULE_GET_API(ACLAddLogEntryByUserName); + VALKEYMODULE_GET_API(DeauthenticateAndCloseClient); + VALKEYMODULE_GET_API(AuthenticateClientWithACLUser); + VALKEYMODULE_GET_API(AuthenticateClientWithUser); + VALKEYMODULE_GET_API(RedactClientCommandArgument); + VALKEYMODULE_GET_API(GetClientCertificate); + VALKEYMODULE_GET_API(GetCommandKeys); + VALKEYMODULE_GET_API(GetCommandKeysWithFlags); + VALKEYMODULE_GET_API(GetCurrentCommandName); + VALKEYMODULE_GET_API(RegisterDefragFunc); + VALKEYMODULE_GET_API(DefragAlloc); + VALKEYMODULE_GET_API(DefragModuleString); + VALKEYMODULE_GET_API(DefragShouldStop); + VALKEYMODULE_GET_API(DefragCursorSet); + VALKEYMODULE_GET_API(DefragCursorGet); + VALKEYMODULE_GET_API(GetKeyNameFromDefragCtx); + VALKEYMODULE_GET_API(GetDbIdFromDefragCtx); + VALKEYMODULE_GET_API(EventLoopAdd); + VALKEYMODULE_GET_API(EventLoopDel); + VALKEYMODULE_GET_API(EventLoopAddOneShot); + VALKEYMODULE_GET_API(RegisterBoolConfig); + VALKEYMODULE_GET_API(RegisterNumericConfig); + VALKEYMODULE_GET_API(RegisterStringConfig); + VALKEYMODULE_GET_API(RegisterEnumConfig); + VALKEYMODULE_GET_API(LoadConfigs); + VALKEYMODULE_GET_API(RdbStreamCreateFromFile); + VALKEYMODULE_GET_API(RdbStreamFree); + VALKEYMODULE_GET_API(RdbLoad); + VALKEYMODULE_GET_API(RdbSave); + + if (ValkeyModule_IsModuleNameBusy && ValkeyModule_IsModuleNameBusy(name)) return VALKEYMODULE_ERR; + ValkeyModule_SetModuleAttribs(ctx,name,ver,apiver); + return VALKEYMODULE_OK; +} + +#define ValkeyModule_Assert(_e) ((_e)?(void)0 : (ValkeyModule__Assert(#_e,__FILE__,__LINE__),exit(1))) + +#define RMAPI_FUNC_SUPPORTED(func) (func != NULL) + +#endif /* VALKEYMODULE_CORE */ +#endif /* VALKEYMODULE_H */