Rename module-related macros

Signed-off-by: Drew DeVault <sir@cmpwn.com>
This commit is contained in:
Drew DeVault 2024-03-22 17:29:44 +01:00
parent bf48df17d2
commit 357df99abb
19 changed files with 2826 additions and 2826 deletions

View File

@ -51,55 +51,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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_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, REDICTMODULE_REPLY_VERBATIM_STRING, proto, proto_len, REPLY_FLAG_RESP3);
rep->len = len;
rep->val.verbatim_str.str = str;
rep->val.verbatim_str.format = format;
@ -107,14 +107,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, REDICTMODULE_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, REDICTMODULE_REPLY_BOOL, proto, proto_len, REPLY_FLAG_RESP3);
rep->val.ll = val;
}
@ -142,7 +142,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 = REDICTMODULE_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;
@ -158,39 +158,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 = REDICTMODULE_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 = REDICTMODULE_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 = REDICTMODULE_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 = REDICTMODULE_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 == REDICTMODULE_REPLY_ARRAY || rep->type == REDICTMODULE_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 == REDICTMODULE_REPLY_MAP || rep->type == REDICTMODULE_REPLY_ATTRIBUTE) {
for (size_t i = 0 ; i < rep->len ; ++i) {
freeCallReplyInternal(rep->val.array + i * 2);
freeCallReplyInternal(rep->val.array + i * 2 + 1);
@ -212,7 +212,7 @@ void freeCallReply(CallReply *rep) {
return;
}
if (rep->flags & REPLY_FLAG_PARSED) {
if (rep->type == REDISMODULE_REPLY_PROMISE) {
if (rep->type == REDICTMODULE_REPLY_PROMISE) {
zfree(rep);
return;
}
@ -226,7 +226,7 @@ void freeCallReply(CallReply *rep) {
CallReply *callReplyCreatePromise(void *private_data) {
CallReply *res = zmalloc(sizeof(*res));
res->type = REDISMODULE_REPLY_PROMISE;
res->type = REDICTMODULE_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. */
@ -267,16 +267,16 @@ static void callReplyParse(CallReply *rep) {
rep->flags |= REPLY_FLAG_PARSED;
}
/* Return the call reply type (REDISMODULE_REPLY_...). */
/* Return the call reply type (REDICTMODULE_REPLY_...). */
int callReplyType(CallReply *rep) {
if (!rep) return REDISMODULE_REPLY_UNKNOWN;
if (!rep) return REDICTMODULE_REPLY_UNKNOWN;
callReplyParse(rep);
return rep->type;
}
/* Return reply string as buffer and len. Applicable to:
* - REDISMODULE_REPLY_STRING
* - REDISMODULE_REPLY_ERROR
* - REDICTMODULE_REPLY_STRING
* - REDICTMODULE_REPLY_ERROR
*
* The return value is borrowed from CallReply, so it must not be freed
* explicitly or used after CallReply itself is freed.
@ -286,56 +286,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 != REDICTMODULE_REPLY_STRING &&
rep->type != REDICTMODULE_REPLY_ERROR) return NULL;
if (len) *len = rep->len;
return rep->val.str;
}
/* Return a long long reply value. Applicable to:
* - REDISMODULE_REPLY_INTEGER
* - REDICTMODULE_REPLY_INTEGER
*/
long long callReplyGetLongLong(CallReply *rep) {
callReplyParse(rep);
if (rep->type != REDISMODULE_REPLY_INTEGER) return LLONG_MIN;
if (rep->type != REDICTMODULE_REPLY_INTEGER) return LLONG_MIN;
return rep->val.ll;
}
/* Return a double reply value. Applicable to:
* - REDISMODULE_REPLY_DOUBLE
* - REDICTMODULE_REPLY_DOUBLE
*/
double callReplyGetDouble(CallReply *rep) {
callReplyParse(rep);
if (rep->type != REDISMODULE_REPLY_DOUBLE) return LLONG_MIN;
if (rep->type != REDICTMODULE_REPLY_DOUBLE) return LLONG_MIN;
return rep->val.d;
}
/* Return a reply Boolean value. Applicable to:
* - REDISMODULE_REPLY_BOOL
* - REDICTMODULE_REPLY_BOOL
*/
int callReplyGetBool(CallReply *rep) {
callReplyParse(rep);
if (rep->type != REDISMODULE_REPLY_BOOL) return INT_MIN;
if (rep->type != REDICTMODULE_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
* - REDICTMODULE_REPLY_STRING
* - REDICTMODULE_REPLY_ERROR
* - REDICTMODULE_REPLY_ARRAY
* - REDICTMODULE_REPLY_SET
* - REDICTMODULE_REPLY_MAP
* - REDICTMODULE_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 REDICTMODULE_REPLY_STRING:
case REDICTMODULE_REPLY_ERROR:
case REDICTMODULE_REPLY_ARRAY:
case REDICTMODULE_REPLY_SET:
case REDICTMODULE_REPLY_MAP:
case REDICTMODULE_REPLY_ATTRIBUTE:
return rep->len;
default:
return 0;
@ -348,26 +348,26 @@ static CallReply *callReplyGetCollectionElement(CallReply *rep, size_t idx, int
}
/* Return a reply array element at a given index. Applicable to:
* - REDISMODULE_REPLY_ARRAY
* - REDICTMODULE_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 != REDICTMODULE_REPLY_ARRAY) return NULL;
return callReplyGetCollectionElement(rep, idx, 1);
}
/* Return a reply set element at a given index. Applicable to:
* - REDISMODULE_REPLY_SET
* - REDICTMODULE_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 != REDICTMODULE_REPLY_SET) return NULL;
return callReplyGetCollectionElement(rep, idx, 1);
}
@ -381,7 +381,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
* - REDICTMODULE_REPLY_MAP
*
* The key and value are returned by reference through key and val,
* which may also be NULL if not needed.
@ -393,7 +393,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, REDICTMODULE_REPLY_MAP);
}
/* Return reply attribute, or NULL if it does not exist. Applicable to all replies.
@ -406,7 +406,7 @@ CallReply *callReplyGetAttribute(CallReply *rep) {
}
/* Retrieve attribute reply key and value at a given index. Applicable to:
* - REDISMODULE_REPLY_ATTRIBUTE
* - REDICTMODULE_REPLY_ATTRIBUTE
*
* The key and value are returned by reference through key and val,
* which may also be NULL if not needed.
@ -418,11 +418,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, REDICTMODULE_REPLY_MAP);
}
/* Return a big number reply value. Applicable to:
* - REDISMODULE_REPLY_BIG_NUMBER
* - REDICTMODULE_REPLY_BIG_NUMBER
*
* The returned values are borrowed from CallReply, so they must not be freed
* explicitly or used after CallReply itself is freed.
@ -435,13 +435,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 != REDICTMODULE_REPLY_BIG_NUMBER) return NULL;
*len = rep->len;
return rep->val.str;
}
/* Return a verbatim string reply value. Applicable to:
* - REDISMODULE_REPLY_VERBATIM_STRING
* - REDICTMODULE_REPLY_VERBATIM_STRING
*
* If format is non-NULL, the verbatim reply format is also returned by value.
*
@ -456,7 +456,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 != REDICTMODULE_REPLY_VERBATIM_STRING) return NULL;
*len = rep->len;
if (format) *format = rep->val.verbatim_str.format;
return rep->val.verbatim_str.str;

View File

@ -913,7 +913,7 @@ void configSetCommand(client *c) {
}
RedictModuleConfigChangeV1 cc = {.num_changes = config_count, .config_names = config_names};
moduleFireServerEvent(REDISMODULE_EVENT_CONFIG, REDISMODULE_SUBEVENT_CONFIG_CHANGE, &cc);
moduleFireServerEvent(REDICTMODULE_EVENT_CONFIG, REDICTMODULE_SUBEVENT_CONFIG_CHANGE, &cc);
addReply(c,shared.ok);
goto end;

View File

@ -502,7 +502,7 @@ long long emptyDbStructure(redictDb *dbarray, int dbnum, int async,
long long emptyData(int dbnum, int flags, void(callback)(dict*)) {
int async = (flags & EMPTYDB_ASYNC);
int with_functions = !(flags & EMPTYDB_NOFUNCTIONS);
RedictModuleFlushInfoV1 fi = {REDISMODULE_FLUSHINFO_VERSION,!async,dbnum};
RedictModuleFlushInfoV1 fi = {REDICTMODULE_FLUSHINFO_VERSION,!async,dbnum};
long long removed = 0;
if (dbnum < -1 || dbnum >= server.dbnum) {
@ -511,8 +511,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(REDICTMODULE_EVENT_FLUSHDB,
REDICTMODULE_SUBEVENT_FLUSHDB_START,
&fi);
/* Make sure the WATCHed keys are affected by the FLUSH* commands.
@ -532,8 +532,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(REDICTMODULE_EVENT_FLUSHDB,
REDICTMODULE_SUBEVENT_FLUSHDB_END,
&fi);
return removed;
@ -843,7 +843,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)REDICTMODULE_TYPE_SIGN(((moduleValue *)o->ptr)->type->id);
if (target != -mt)
return 0;
else
@ -929,7 +929,7 @@ long long getObjectTypeByName(char *name) {
}
moduleType *mt = moduleTypeLookupModuleByNameIgnoreCase(name);
if (mt != NULL) return -(REDISMODULE_TYPE_SIGN(mt->id));
if (mt != NULL) return -(REDICTMODULE_TYPE_SIGN(mt->id));
return LLONG_MAX;
}
@ -1657,8 +1657,8 @@ void swapdbCommand(client *c) {
addReplyError(c,"DB index is out of range");
return;
} else {
RedictModuleSwapDbInfo si = {REDISMODULE_SWAPDBINFO_VERSION,id1,id2};
moduleFireServerEvent(REDISMODULE_EVENT_SWAPDB,0,&si);
RedictModuleSwapDbInfo si = {REDICTMODULE_SWAPDBINFO_VERSION,id1,id2};
moduleFireServerEvent(REDICTMODULE_EVENT_SWAPDB,0,&si);
server.dirty++;
addReply(c,shared.ok);
}

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@ static uint64_t global_auth_client_id = 0;
/* HELLOACL.REVOKE
* Synchronously revoke access from a user. */
int RevokeCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (global_auth_client_id) {
RedictModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id);
@ -29,8 +29,8 @@ int RevokeCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
/* HELLOACL.RESET
* Synchronously delete and re-create a module user. */
int ResetCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModule_FreeModuleUser(global);
global = RedictModule_CreateModuleUser("global");
@ -44,16 +44,16 @@ int ResetCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
/* 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);
REDICTMODULE_NOT_USED(privdata);
REDICTMODULE_NOT_USED(client_id);
global_auth_client_id = 0;
}
/* HELLOACL.AUTHGLOBAL
* Synchronously assigns a module user to the current context. */
int AuthGlobalCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (global_auth_client_id) {
return RedictModule_ReplyWithError(ctx, "Global user currently used");
@ -68,15 +68,15 @@ int AuthGlobalCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **ar
/* Reply callback for auth command HELLOACL.AUTHASYNC */
int HelloACL_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
size_t length;
RedictModuleString *user_string = RedictModule_GetBlockedClientPrivateData(ctx);
const char *name = RedictModule_StringPtrLen(user_string, &length);
if (RedictModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) ==
REDISMODULE_ERR) {
REDICTMODULE_ERR) {
return RedictModule_ReplyWithError(ctx, "Invalid Username or password");
}
return RedictModule_ReplyWithSimpleString(ctx, "OK");
@ -84,14 +84,14 @@ int HelloACL_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
/* Timeout callback for auth command HELLOACL.AUTHASYNC */
int HelloACL_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
return RedictModule_ReplyWithSimpleString(ctx, "Request timedout");
}
/* Private data frees data for HELLOACL.AUTHASYNC command. */
void HelloACL_FreeData(RedictModuleCtx *ctx, void *privdata) {
REDISMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(ctx);
RedictModule_FreeString(NULL, privdata);
}
@ -124,33 +124,33 @@ int AuthAsyncCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **arg
return RedictModule_ReplyWithError(ctx, "-ERR Can't start thread");
}
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"helloacl",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"helloacl",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.reset",
ResetCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
ResetCommand_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.revoke",
RevokeCommand_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
RevokeCommand_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.authglobal",
AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.authasync",
AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
global = RedictModule_CreateModuleUser("global");
RedictModule_SetModuleUserACL(global, "allcommands");
@ -159,5 +159,5 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
global_auth_client_id = 0;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -12,22 +12,22 @@
/* Reply callback for blocking command HELLO.BLOCK */
int HelloBlock_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
int *myint = RedictModule_GetBlockedClientPrivateData(ctx);
return RedictModule_ReplyWithLongLong(ctx,*myint);
}
/* Timeout callback for blocking command HELLO.BLOCK */
int HelloBlock_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
return RedictModule_ReplyWithSimpleString(ctx,"Request timedout");
}
/* Private data freeing callback for HELLO.BLOCK command. */
void HelloBlock_FreeData(RedictModuleCtx *ctx, void *privdata) {
REDISMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(ctx);
RedictModule_Free(privdata);
}
@ -71,11 +71,11 @@ int HelloBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
long long delay;
long long timeout;
if (RedictModule_StringToLongLong(argv[1],&delay) != REDISMODULE_OK) {
if (RedictModule_StringToLongLong(argv[1],&delay) != REDICTMODULE_OK) {
return RedictModule_ReplyWithError(ctx,"ERR invalid count");
}
if (RedictModule_StringToLongLong(argv[2],&timeout) != REDISMODULE_OK) {
if (RedictModule_StringToLongLong(argv[2],&timeout) != REDICTMODULE_OK) {
return RedictModule_ReplyWithError(ctx,"ERR invalid count");
}
@ -98,7 +98,7 @@ int HelloBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
RedictModule_AbortBlock(bc);
return RedictModule_ReplyWithError(ctx,"-ERR Can't start thread");
}
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* The thread entry point that actually executes the blocking part
@ -114,7 +114,7 @@ void *HelloKeys_ThreadMain(void *arg) {
long long cursor = 0;
size_t replylen = 0;
RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
RedictModule_ReplyWithArray(ctx,REDICTMODULE_POSTPONED_LEN);
do {
RedictModule_ThreadSafeContextLock(ctx);
RedictModuleCallReply *reply = RedictModule_Call(ctx,
@ -151,7 +151,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(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argv);
if (argc != 1) return RedictModule_WrongArity(ctx);
pthread_t tid;
@ -168,24 +168,24 @@ int HelloKeys_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
RedictModule_AbortBlock(bc);
return RedictModule_ReplyWithError(ctx,"-ERR Can't start thread");
}
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"helloblock",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"helloblock",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.block",
HelloBlock_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloBlock_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.keys",
HelloKeys_RedisCommand,"",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloKeys_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -15,8 +15,8 @@
/* HELLOCLUSTER.PINGALL */
int PingallCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModule_SendClusterMessage(ctx,NULL,MSGTYPE_PING,"Hey",3);
return RedictModule_ReplyWithSimpleString(ctx, "OK");
@ -24,8 +24,8 @@ int PingallCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
/* HELLOCLUSTER.LIST */
int ListCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
size_t numnodes;
char **ids = RedictModule_GetClusterNodesList(ctx,&numnodes);
@ -38,17 +38,17 @@ int ListCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, in
int port;
RedictModule_GetClusterNodeInfo(ctx,ids[j],NULL,NULL,&port,NULL);
RedictModule_ReplyWithArray(ctx,2);
RedictModule_ReplyWithStringBuffer(ctx,ids[j],REDISMODULE_NODE_ID_LEN);
RedictModule_ReplyWithStringBuffer(ctx,ids[j],REDICTMODULE_NODE_ID_LEN);
RedictModule_ReplyWithLongLong(ctx,port);
}
RedictModule_FreeClusterNodesList(ids);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* Callback for message MSGTYPE_PING */
void PingReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) {
RedictModule_Log(ctx,"notice","PING (type %d) RECEIVED from %.*s: '%.*s'",
type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
type,REDICTMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
RedictModule_SendClusterMessage(ctx,NULL,MSGTYPE_PONG,"Ohi!",4);
RedictModuleCallReply *reply = RedictModule_Call(ctx, "INCR", "c", "pings_received");
RedictModule_FreeCallReply(reply);
@ -57,25 +57,25 @@ void PingReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, con
/* Callback for message MSGTYPE_PONG. */
void PongReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, const unsigned char *payload, uint32_t len) {
RedictModule_Log(ctx,"notice","PONG (type %d) RECEIVED from %.*s: '%.*s'",
type,REDISMODULE_NODE_ID_LEN,sender_id,(int)len, payload);
type,REDICTMODULE_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 RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"hellocluster",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"hellocluster",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellocluster.pingall",
PingallCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
PingallCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellocluster.list",
ListCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
ListCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
/* Disable Redis Cluster sharding and redirections. This way every node
* will be able to access every possible key, regardless of the hash slot.
@ -83,10 +83,10 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
* variable. Normally you do that in order for the distributed system
* you create as a module to have total freedom in the keyspace
* manipulation. */
RedictModule_SetClusterFlags(ctx,REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION);
RedictModule_SetClusterFlags(ctx,REDICTMODULE_CLUSTER_FLAG_NO_REDIRECTION);
/* Register our handlers for different message types. */
RedictModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PING,PingReceiver);
RedictModule_RegisterClusterMessageReceiver(ctx,MSGTYPE_PONG,PongReceiver);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -47,7 +47,7 @@ int cmd_KEYRANGE(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
/* Parse the count argument. */
long long count;
if (RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) {
if (RedictModule_StringToLongLong(argv[3],&count) != REDICTMODULE_OK) {
return RedictModule_ReplyWithError(ctx,"ERR invalid count");
}
@ -59,10 +59,10 @@ int cmd_KEYRANGE(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
char *key;
size_t keylen;
long long replylen = 0; /* Keep track of the emitted array len. */
RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
RedictModule_ReplyWithArray(ctx,REDICTMODULE_POSTPONED_LEN);
while((key = RedictModule_DictNextC(iter,&keylen,NULL)) != NULL) {
if (replylen >= count) break;
if (RedictModule_DictCompare(iter,"<=",argv[2]) == REDISMODULE_ERR)
if (RedictModule_DictCompare(iter,"<=",argv[2]) == REDICTMODULE_ERR)
break;
RedictModule_ReplyWithStringBuffer(ctx,key,keylen);
replylen++;
@ -71,32 +71,32 @@ int cmd_KEYRANGE(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
/* Cleanup. */
RedictModule_DictIteratorStop(iter);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"hellodict",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"hellodict",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellodict.get",
cmd_GET,"readonly",1,1,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
cmd_GET,"readonly",1,1,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellodict.keyrange",
cmd_KEYRANGE,"readonly",1,1,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
cmd_KEYRANGE,"readonly",1,1,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
/* Create our global dictionary. Here we'll set our keys and values. */
Keyspace = RedictModule_CreateDict(NULL);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -13,23 +13,23 @@
/* Client state change callback. */
void clientChangeCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, void *data)
{
REDISMODULE_NOT_USED(ctx);
REDISMODULE_NOT_USED(e);
REDICTMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(e);
RedictModuleClientInfo *ci = data;
printf("Client %s event for client #%llu %s:%d\n",
(sub == REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ?
(sub == REDICTMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED) ?
"connection" : "disconnection",
(unsigned long long)ci->id,ci->addr,ci->port);
}
void flushdbCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, void *data)
{
REDISMODULE_NOT_USED(ctx);
REDISMODULE_NOT_USED(e);
REDICTMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(e);
RedictModuleFlushInfo *fi = data;
if (sub == REDISMODULE_SUBEVENT_FLUSHDB_START) {
if (sub == REDICTMODULE_SUBEVENT_FLUSHDB_START) {
if (fi->dbnum != -1) {
RedictModuleCallReply *reply;
reply = RedictModule_Call(ctx,"DBSIZE","");
@ -52,15 +52,15 @@ void flushdbCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, vo
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"hellohook",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"hellohook",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
RedictModule_SubscribeToServerEvent(ctx,
RedictModuleEvent_ClientChange, clientChangeCallback);
RedictModule_SubscribeToServerEvent(ctx,
RedictModuleEvent_FlushDB, flushdbCallback);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -12,22 +12,22 @@
/* Timer callback. */
void timerHandler(RedictModuleCtx *ctx, void *data) {
REDISMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(ctx);
printf("Fired %s!\n", (char *)data);
RedictModule_Free(data);
}
/* HELLOTIMER.TIMER*/
int TimerCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
for (int j = 0; j < 10; j++) {
int delay = rand() % 5000;
char *buf = RedictModule_Alloc(256);
snprintf(buf,256,"After %d", delay);
RedictModuleTimerID tid = RedictModule_CreateTimer(ctx,delay,timerHandler,buf);
REDISMODULE_NOT_USED(tid);
REDICTMODULE_NOT_USED(tid);
}
return RedictModule_ReplyWithSimpleString(ctx, "OK");
}
@ -35,15 +35,15 @@ int TimerCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"hellotimer",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"hellotimer",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotimer.timer",
TimerCommand_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
TimerCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -74,22 +74,22 @@ int HelloTypeInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
if (argc != 3) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_EMPTY &&
if (type != REDICTMODULE_KEYTYPE_EMPTY &&
RedictModule_ModuleTypeGetType(key) != HelloType)
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
long long value;
if ((RedictModule_StringToLongLong(argv[2],&value) != REDISMODULE_OK)) {
if ((RedictModule_StringToLongLong(argv[2],&value) != REDICTMODULE_OK)) {
return RedictModule_ReplyWithError(ctx,"ERR invalid value: must be a signed 64 bit integer");
}
/* Create an empty value object if the key is currently empty. */
struct HelloTypeObject *hto;
if (type == REDISMODULE_KEYTYPE_EMPTY) {
if (type == REDICTMODULE_KEYTYPE_EMPTY) {
hto = createHelloTypeObject();
RedictModule_ModuleTypeSetValue(key,HelloType,hto);
} else {
@ -102,7 +102,7 @@ int HelloTypeInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
RedictModule_ReplyWithLongLong(ctx,hto->len);
RedictModule_ReplicateVerbatim(ctx);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLOTYPE.RANGE key first count */
@ -111,17 +111,17 @@ int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
if (argc != 4) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_EMPTY &&
if (type != REDICTMODULE_KEYTYPE_EMPTY &&
RedictModule_ModuleTypeGetType(key) != HelloType)
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
long long first, count;
if (RedictModule_StringToLongLong(argv[2],&first) != REDISMODULE_OK ||
RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK ||
if (RedictModule_StringToLongLong(argv[2],&first) != REDICTMODULE_OK ||
RedictModule_StringToLongLong(argv[3],&count) != REDICTMODULE_OK ||
first < 0 || count < 0)
{
return RedictModule_ReplyWithError(ctx,
@ -130,7 +130,7 @@ int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
struct HelloTypeObject *hto = RedictModule_ModuleTypeGetValue(key);
struct HelloTypeNode *node = hto ? hto->head : NULL;
RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
RedictModule_ReplyWithArray(ctx,REDICTMODULE_POSTPONED_LEN);
long long arraylen = 0;
while(node && count--) {
RedictModule_ReplyWithLongLong(ctx,node->value);
@ -138,7 +138,7 @@ int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
node = node->next;
}
RedictModule_ReplySetArrayLength(ctx,arraylen);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLOTYPE.LEN key */
@ -147,17 +147,17 @@ int HelloTypeLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
if (argc != 2) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_EMPTY &&
if (type != REDICTMODULE_KEYTYPE_EMPTY &&
RedictModule_ModuleTypeGetType(key) != HelloType)
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
struct HelloTypeObject *hto = RedictModule_ModuleTypeGetValue(key);
RedictModule_ReplyWithLongLong(ctx,hto ? hto->len : 0);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* ====================== Example of a blocking command ==================== */
@ -166,17 +166,17 @@ int HelloTypeLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
* 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(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModuleString *keyname = RedictModule_GetBlockedClientReadyKey(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,keyname,REDISMODULE_READ);
RedictModuleKey *key = RedictModule_OpenKey(ctx,keyname,REDICTMODULE_READ);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_MODULE ||
if (type != REDICTMODULE_KEYTYPE_MODULE ||
RedictModule_ModuleTypeGetType(key) != HelloType)
{
RedictModule_CloseKey(key);
return REDISMODULE_ERR;
return REDICTMODULE_ERR;
}
/* In case the key is able to serve our blocked client, let's directly
@ -187,14 +187,14 @@ int HelloBlock_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
/* Timeout callback for blocking command HELLOTYPE.BRANGE */
int HelloBlock_Timeout(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
return RedictModule_ReplyWithSimpleString(ctx,"Request timedout");
}
/* Private data freeing callback for HELLOTYPE.BRANGE command. */
void HelloBlock_FreeData(RedictModuleCtx *ctx, void *privdata) {
REDISMODULE_NOT_USED(ctx);
REDICTMODULE_NOT_USED(ctx);
RedictModule_Free(privdata);
}
@ -205,31 +205,31 @@ int HelloTypeBRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
if (argc != 5) return RedictModule_WrongArity(ctx);
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_EMPTY &&
if (type != REDICTMODULE_KEYTYPE_EMPTY &&
RedictModule_ModuleTypeGetType(key) != HelloType)
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_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 (RedictModule_StringToLongLong(argv[4],&timeout) != REDISMODULE_OK) {
if (RedictModule_StringToLongLong(argv[4],&timeout) != REDICTMODULE_OK) {
return RedictModule_ReplyWithError(ctx,
"ERR invalid timeout parameter");
}
/* Can we serve the reply synchronously? */
if (type != REDISMODULE_KEYTYPE_EMPTY) {
if (type != REDICTMODULE_KEYTYPE_EMPTY) {
return HelloTypeRange_RedisCommand(ctx,argv,argc-1);
}
/* Otherwise let's block on the key. */
void *privdata = RedictModule_Alloc(100);
RedictModule_BlockClientOnKeys(ctx,HelloBlock_Reply,HelloBlock_Timeout,HelloBlock_FreeData,timeout,argv+1,1,privdata);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* ========================== "hellotype" type methods ======================= */
@ -292,14 +292,14 @@ void HelloTypeDigest(RedictModuleDigest *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 RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (RedictModule_Init(ctx,"hellotype",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"hellotype",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
RedictModuleTypeMethods tm = {
.version = REDISMODULE_TYPE_METHOD_VERSION,
.version = REDICTMODULE_TYPE_METHOD_VERSION,
.rdb_load = HelloTypeRdbLoad,
.rdb_save = HelloTypeRdbSave,
.aof_rewrite = HelloTypeAofRewrite,
@ -309,23 +309,23 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
};
HelloType = RedictModule_CreateDataType(ctx,"hellotype",0,&tm);
if (HelloType == NULL) return REDISMODULE_ERR;
if (HelloType == NULL) return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.range",
HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.len",
HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.brange",
HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -16,10 +16,10 @@
* fetch the currently selected DB, the other in order to send the client
* an integer reply as response. */
int HelloSimple_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModule_ReplyWithLongLong(ctx,RedictModule_GetSelectedDb(ctx));
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.PUSH.NATIVE re-implements RPUSH, and shows the low level modules API
@ -33,13 +33,13 @@ int HelloPushNative_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
if (argc != 3) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
RedictModule_ListPush(key,REDISMODULE_LIST_TAIL,argv[2]);
RedictModule_ListPush(key,REDICTMODULE_LIST_TAIL,argv[2]);
size_t newlen = RedictModule_ValueLength(key);
RedictModule_CloseKey(key);
RedictModule_ReplyWithLongLong(ctx,newlen);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling
@ -57,7 +57,7 @@ int HelloPushCall_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
long long len = RedictModule_CallReplyInteger(reply);
RedictModule_FreeCallReply(reply);
RedictModule_ReplyWithLongLong(ctx,len);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.PUSH.CALL2
@ -72,7 +72,7 @@ int HelloPushCall2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
reply = RedictModule_Call(ctx,"RPUSH","ss",argv[1],argv[2]);
RedictModule_ReplyWithCallReply(ctx,reply);
RedictModule_FreeCallReply(reply);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.LIST.SUM.LEN returns the total length of all the items inside
@ -94,7 +94,7 @@ int HelloListSumLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
}
RedictModule_FreeCallReply(reply);
RedictModule_ReplyWithLongLong(ctx,strlen);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.LIST.SPLICE srclist dstlist count
@ -105,23 +105,23 @@ int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
if (argc != 4) return RedictModule_WrongArity(ctx);
RedictModuleKey *srckey = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
RedictModuleKey *dstkey = RedictModule_OpenKey(ctx,argv[2],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
/* Src and dst key must be empty or lists. */
if ((RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) ||
(RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY))
if ((RedictModule_KeyType(srckey) != REDICTMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(srckey) != REDICTMODULE_KEYTYPE_EMPTY) ||
(RedictModule_KeyType(dstkey) != REDICTMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(dstkey) != REDICTMODULE_KEYTYPE_EMPTY))
{
RedictModule_CloseKey(srckey);
RedictModule_CloseKey(dstkey);
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
long long count;
if ((RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) ||
if ((RedictModule_StringToLongLong(argv[3],&count) != REDICTMODULE_OK) ||
(count < 0)) {
RedictModule_CloseKey(srckey);
RedictModule_CloseKey(dstkey);
@ -131,9 +131,9 @@ int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
while(count-- > 0) {
RedictModuleString *ele;
ele = RedictModule_ListPop(srckey,REDISMODULE_LIST_TAIL);
ele = RedictModule_ListPop(srckey,REDICTMODULE_LIST_TAIL);
if (ele == NULL) break;
RedictModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele);
RedictModule_ListPush(dstkey,REDICTMODULE_LIST_HEAD,ele);
RedictModule_FreeString(ctx,ele);
}
@ -141,7 +141,7 @@ int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
RedictModule_CloseKey(srckey);
RedictModule_CloseKey(dstkey);
RedictModule_ReplyWithLongLong(ctx,len);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* Like the HELLO.LIST.SPLICE above, but uses automatic memory management
@ -152,21 +152,21 @@ int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **
RedictModule_AutoMemory(ctx);
RedictModuleKey *srckey = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
RedictModuleKey *dstkey = RedictModule_OpenKey(ctx,argv[2],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
/* Src and dst key must be empty or lists. */
if ((RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(srckey) != REDISMODULE_KEYTYPE_EMPTY) ||
(RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(dstkey) != REDISMODULE_KEYTYPE_EMPTY))
if ((RedictModule_KeyType(srckey) != REDICTMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(srckey) != REDICTMODULE_KEYTYPE_EMPTY) ||
(RedictModule_KeyType(dstkey) != REDICTMODULE_KEYTYPE_LIST &&
RedictModule_KeyType(dstkey) != REDICTMODULE_KEYTYPE_EMPTY))
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
long long count;
if ((RedictModule_StringToLongLong(argv[3],&count) != REDISMODULE_OK) ||
if ((RedictModule_StringToLongLong(argv[3],&count) != REDICTMODULE_OK) ||
(count < 0))
{
return RedictModule_ReplyWithError(ctx,"ERR invalid count");
@ -175,14 +175,14 @@ int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **
while(count-- > 0) {
RedictModuleString *ele;
ele = RedictModule_ListPop(srckey,REDISMODULE_LIST_TAIL);
ele = RedictModule_ListPop(srckey,REDICTMODULE_LIST_TAIL);
if (ele == NULL) break;
RedictModule_ListPush(dstkey,REDISMODULE_LIST_HEAD,ele);
RedictModule_ListPush(dstkey,REDICTMODULE_LIST_HEAD,ele);
}
size_t len = RedictModule_ValueLength(srckey);
RedictModule_ReplyWithLongLong(ctx,len);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.RAND.ARRAY <count>
@ -191,7 +191,7 @@ int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **
int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 2) return RedictModule_WrongArity(ctx);
long long count;
if (RedictModule_StringToLongLong(argv[1],&count) != REDISMODULE_OK ||
if (RedictModule_StringToLongLong(argv[1],&count) != REDICTMODULE_OK ||
count < 0)
return RedictModule_ReplyWithError(ctx,"ERR invalid count");
@ -200,7 +200,7 @@ int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
* the elements of the array. */
RedictModule_ReplyWithArray(ctx,count);
while(count--) RedictModule_ReplyWithLongLong(ctx,rand());
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This is a simple command to test replication. Because of the "!" modified
@ -209,8 +209,8 @@ int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
* comments the function implementation). */
int HelloRepl1_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModule_AutoMemory(ctx);
/* This will be replicated *after* the two INCR statements, since
@ -232,7 +232,7 @@ int HelloRepl1_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
RedictModule_ReplyWithLongLong(ctx,0);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* Another command to show replication. In this case, we call
@ -250,27 +250,27 @@ int HelloRepl2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_LIST)
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
if (RedictModule_KeyType(key) != REDICTMODULE_KEYTYPE_LIST)
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
size_t listlen = RedictModule_ValueLength(key);
long long sum = 0;
/* Rotate and increment. */
while(listlen--) {
RedictModuleString *ele = RedictModule_ListPop(key,REDISMODULE_LIST_TAIL);
RedictModuleString *ele = RedictModule_ListPop(key,REDICTMODULE_LIST_TAIL);
long long val;
if (RedictModule_StringToLongLong(ele,&val) != REDISMODULE_OK) val = 0;
if (RedictModule_StringToLongLong(ele,&val) != REDICTMODULE_OK) val = 0;
val++;
sum += val;
RedictModuleString *newele = RedictModule_CreateStringFromLongLong(ctx,val);
RedictModule_ListPush(key,REDISMODULE_LIST_HEAD,newele);
RedictModule_ListPush(key,REDICTMODULE_LIST_HEAD,newele);
}
RedictModule_ReplyWithLongLong(ctx,sum);
RedictModule_ReplicateVerbatim(ctx);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This is an example of strings DMA access. Given a key containing a string
@ -285,19 +285,19 @@ int HelloToggleCase_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
if (argc != 2) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int keytype = RedictModule_KeyType(key);
if (keytype != REDISMODULE_KEYTYPE_STRING &&
keytype != REDISMODULE_KEYTYPE_EMPTY)
if (keytype != REDICTMODULE_KEYTYPE_STRING &&
keytype != REDICTMODULE_KEYTYPE_EMPTY)
{
RedictModule_CloseKey(key);
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
if (keytype == REDISMODULE_KEYTYPE_STRING) {
if (keytype == REDICTMODULE_KEYTYPE_STRING) {
size_t len, j;
char *s = RedictModule_StringDMA(key,&len,REDISMODULE_WRITE);
char *s = RedictModule_StringDMA(key,&len,REDICTMODULE_WRITE);
for (j = 0; j < len; j++) {
if (isupper(s[j])) {
s[j] = tolower(s[j]);
@ -310,7 +310,7 @@ int HelloToggleCase_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
RedictModule_CloseKey(key);
RedictModule_ReplyWithSimpleString(ctx,"OK");
RedictModule_ReplicateVerbatim(ctx);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.MORE.EXPIRE key milliseconds.
@ -323,13 +323,13 @@ int HelloMoreExpire_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
mstime_t addms, expire;
if (RedictModule_StringToLongLong(argv[2],&addms) != REDISMODULE_OK)
if (RedictModule_StringToLongLong(argv[2],&addms) != REDICTMODULE_OK)
return RedictModule_ReplyWithError(ctx,"ERR invalid expire time");
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
expire = RedictModule_GetExpire(key);
if (expire != REDISMODULE_NO_EXPIRE) {
if (expire != REDICTMODULE_NO_EXPIRE) {
expire += addms;
RedictModule_SetExpire(key,expire);
}
@ -346,16 +346,16 @@ int HelloZsumRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
double score_start, score_end;
if (argc != 4) return RedictModule_WrongArity(ctx);
if (RedictModule_StringToDouble(argv[2],&score_start) != REDISMODULE_OK ||
RedictModule_StringToDouble(argv[3],&score_end) != REDISMODULE_OK)
if (RedictModule_StringToDouble(argv[2],&score_start) != REDICTMODULE_OK ||
RedictModule_StringToDouble(argv[3],&score_end) != REDICTMODULE_OK)
{
return RedictModule_ReplyWithError(ctx,"ERR invalid range");
}
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) {
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
if (RedictModule_KeyType(key) != REDICTMODULE_KEYTYPE_ZSET) {
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
double scoresum_a = 0;
@ -387,7 +387,7 @@ int HelloZsumRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
RedictModule_ReplyWithArray(ctx,2);
RedictModule_ReplyWithDouble(ctx,scoresum_a);
RedictModule_ReplyWithDouble(ctx,scoresum_b);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.LEXRANGE key min_lex max_lex min_age max_age
@ -403,17 +403,17 @@ int HelloLexRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
if (argc != 6) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
if (RedictModule_KeyType(key) != REDISMODULE_KEYTYPE_ZSET) {
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
if (RedictModule_KeyType(key) != REDICTMODULE_KEYTYPE_ZSET) {
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
if (RedictModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDISMODULE_OK) {
if (RedictModule_ZsetFirstInLexRange(key,argv[2],argv[3]) != REDICTMODULE_OK) {
return RedictModule_ReplyWithError(ctx,"invalid range");
}
int arraylen = 0;
RedictModule_ReplyWithArray(ctx,REDISMODULE_POSTPONED_LEN);
RedictModule_ReplyWithArray(ctx,REDICTMODULE_POSTPONED_LEN);
while(!RedictModule_ZsetRangeEndReached(key)) {
double score;
RedictModuleString *ele = RedictModule_ZsetRangeCurrentElement(key,&score);
@ -425,7 +425,7 @@ int HelloLexRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
RedictModule_ZsetRangeStop(key);
RedictModule_ReplySetArrayLength(ctx,arraylen);
RedictModule_CloseKey(key);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.HCOPY key srcfield dstfield
@ -440,22 +440,22 @@ int HelloHCopy_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
if (argc != 4) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
REDISMODULE_READ|REDISMODULE_WRITE);
REDICTMODULE_READ|REDICTMODULE_WRITE);
int type = RedictModule_KeyType(key);
if (type != REDISMODULE_KEYTYPE_HASH &&
type != REDISMODULE_KEYTYPE_EMPTY)
if (type != REDICTMODULE_KEYTYPE_HASH &&
type != REDICTMODULE_KEYTYPE_EMPTY)
{
return RedictModule_ReplyWithError(ctx,REDISMODULE_ERRORMSG_WRONGTYPE);
return RedictModule_ReplyWithError(ctx,REDICTMODULE_ERRORMSG_WRONGTYPE);
}
/* Get the old field value. */
RedictModuleString *oldval;
RedictModule_HashGet(key,REDISMODULE_HASH_NONE,argv[2],&oldval,NULL);
RedictModule_HashGet(key,REDICTMODULE_HASH_NONE,argv[2],&oldval,NULL);
if (oldval) {
RedictModule_HashSet(key,REDISMODULE_HASH_NONE,argv[3],oldval,NULL);
RedictModule_HashSet(key,REDICTMODULE_HASH_NONE,argv[3],oldval,NULL);
}
RedictModule_ReplyWithLongLong(ctx,oldval != NULL);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* HELLO.LEFTPAD str len ch
@ -482,7 +482,7 @@ int HelloLeftPad_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
if (argc != 4) return RedictModule_WrongArity(ctx);
if ((RedictModule_StringToLongLong(argv[2],&padlen) != REDISMODULE_OK) ||
if ((RedictModule_StringToLongLong(argv[2],&padlen) != REDICTMODULE_OK) ||
(padlen< 0)) {
return RedictModule_ReplyWithError(ctx,"ERR invalid padding length");
}
@ -507,14 +507,14 @@ int HelloLeftPad_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
memcpy(buf+padlen,str,strlen);
RedictModule_ReplyWithStringBuffer(ctx,buf,padlen+strlen);
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (RedictModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"helloworld",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
/* Log the list of parameters passing loading the module. */
for (int j = 0; j < argc; j++) {
@ -523,69 +523,69 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
}
if (RedictModule_CreateCommand(ctx,"hello.simple",
HelloSimple_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloSimple_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.list.sum.len",
HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloListSumLen_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.rand.array",
HelloRandArray_RedisCommand,"readonly",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloRandArray_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.repl1",
HelloRepl1_RedisCommand,"write",0,0,0) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloRepl1_RedisCommand,"write",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.repl2",
HelloRepl2_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloRepl2_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.toggle.case",
HelloToggleCase_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloToggleCase_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.more.expire",
HelloMoreExpire_RedisCommand,"write",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloMoreExpire_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.zsumrange",
HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.lexrange",
HelloLexRange_RedisCommand,"readonly",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloLexRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_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) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.leftpad",
HelloLeftPad_RedisCommand,"",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
HelloLeftPad_RedisCommand,"",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}

View File

@ -1287,8 +1287,8 @@ void clientAcceptHandler(connection *conn) {
}
server.stat_numconnections++;
moduleFireServerEvent(REDISMODULE_EVENT_CLIENT_CHANGE,
REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED,
moduleFireServerEvent(REDICTMODULE_EVENT_CLIENT_CHANGE,
REDICTMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED,
c);
}
@ -1552,8 +1552,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(REDICTMODULE_EVENT_CLIENT_CHANGE,
REDICTMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED,
c);
}
@ -1673,8 +1673,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(REDICTMODULE_EVENT_REPLICA_CHANGE,
REDICTMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE,
NULL);
}

View File

@ -1373,7 +1373,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, REDICTMODULE_AUX_BEFORE_RDB) == -1) goto werr;
/* save functions */
if (!(req & SLAVE_REQ_RDB_EXCLUDE_FUNCTIONS) && rdbSaveFunctions(rdb) == -1) goto werr;
@ -1385,7 +1385,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, REDICTMODULE_AUX_AFTER_RDB) == -1) goto werr;
/* EOF opcode */
if (rdbSaveType(rdb,RDB_OPCODE_EOF) == -1) goto werr;
@ -2857,12 +2857,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 = REDICTMODULE_SUBEVENT_LOADING_AOF_START;
else if(rdbflags & RDBFLAGS_REPLICATION)
subevent = REDISMODULE_SUBEVENT_LOADING_REPL_START;
subevent = REDICTMODULE_SUBEVENT_LOADING_REPL_START;
else
subevent = REDISMODULE_SUBEVENT_LOADING_RDB_START;
moduleFireServerEvent(REDISMODULE_EVENT_LOADING,subevent,NULL);
subevent = REDICTMODULE_SUBEVENT_LOADING_RDB_START;
moduleFireServerEvent(REDICTMODULE_EVENT_LOADING,subevent,NULL);
}
/* Mark that we are loading in the global state and setup the fields
@ -2900,10 +2900,10 @@ void stopLoading(int success) {
rdbFileBeingLoaded = NULL;
/* Fire the loading modules end event. */
moduleFireServerEvent(REDISMODULE_EVENT_LOADING,
moduleFireServerEvent(REDICTMODULE_EVENT_LOADING,
success?
REDISMODULE_SUBEVENT_LOADING_ENDED:
REDISMODULE_SUBEVENT_LOADING_FAILED,
REDICTMODULE_SUBEVENT_LOADING_ENDED:
REDICTMODULE_SUBEVENT_LOADING_FAILED,
NULL);
}
@ -2911,22 +2911,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 = REDICTMODULE_SUBEVENT_PERSISTENCE_AOF_START;
else if (rdbflags & RDBFLAGS_AOF_PREAMBLE)
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START;
subevent = REDICTMODULE_SUBEVENT_PERSISTENCE_SYNC_AOF_START;
else if (getpid()!=server.pid)
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START;
subevent = REDICTMODULE_SUBEVENT_PERSISTENCE_RDB_START;
else
subevent = REDISMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START;
moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,subevent,NULL);
subevent = REDICTMODULE_SUBEVENT_PERSISTENCE_SYNC_RDB_START;
moduleFireServerEvent(REDICTMODULE_EVENT_PERSISTENCE,subevent,NULL);
}
void stopSaving(int success) {
/* Fire the persistence modules end event. */
moduleFireServerEvent(REDISMODULE_EVENT_PERSISTENCE,
moduleFireServerEvent(REDICTMODULE_EVENT_PERSISTENCE,
success?
REDISMODULE_SUBEVENT_PERSISTENCE_ENDED:
REDISMODULE_SUBEVENT_PERSISTENCE_FAILED,
REDICTMODULE_SUBEVENT_PERSISTENCE_ENDED:
REDICTMODULE_SUBEVENT_PERSISTENCE_FAILED,
NULL);
}
@ -3206,7 +3206,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
moduleFreeContext(io.ctx);
zfree(io.ctx);
}
if (rc != REDISMODULE_OK || io.error) {
if (rc != REDICTMODULE_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;

File diff suppressed because it is too large Load Diff

View File

@ -797,8 +797,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(REDICTMODULE_EVENT_REPLICA_CHANGE,
REDICTMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
NULL);
return C_OK; /* The caller can return, no full resync needed. */
@ -1284,8 +1284,8 @@ int replicaPutOnline(client *slave) {
refreshGoodSlavesCount();
/* Fire the replica change modules event. */
moduleFireServerEvent(REDISMODULE_EVENT_REPLICA_CHANGE,
REDISMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
moduleFireServerEvent(REDICTMODULE_EVENT_REPLICA_CHANGE,
REDICTMODULE_SUBEVENT_REPLICA_CHANGE_ONLINE,
NULL);
serverLog(LL_NOTICE,"Synchronization with replica %s succeeded",
replicationGetSlaveName(slave));
@ -2044,8 +2044,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(REDICTMODULE_EVENT_REPL_ASYNC_LOAD,
REDICTMODULE_SUBEVENT_REPL_ASYNC_LOAD_STARTED,
NULL);
} else {
replicationAttachToNewMaster();
@ -2118,8 +2118,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(REDICTMODULE_EVENT_REPL_ASYNC_LOAD,
REDICTMODULE_SUBEVENT_REPL_ASYNC_LOAD_ABORTED,
NULL);
disklessLoadDiscardTempDb(diskless_load_tempDb);
@ -2149,8 +2149,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(REDICTMODULE_EVENT_REPL_ASYNC_LOAD,
REDICTMODULE_SUBEVENT_REPL_ASYNC_LOAD_COMPLETED,
NULL);
/* Delete the old db as it's useless now. */
@ -2245,8 +2245,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(REDICTMODULE_EVENT_MASTER_LINK_CHANGE,
REDICTMODULE_SUBEVENT_MASTER_LINK_UP,
NULL);
/* After a full resynchronization we use the replication ID and
@ -3020,14 +3020,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(REDICTMODULE_EVENT_REPLICATION_ROLE_CHANGED,
REDICTMODULE_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(REDICTMODULE_EVENT_MASTER_LINK_CHANGE,
REDICTMODULE_SUBEVENT_MASTER_LINK_DOWN,
NULL);
server.repl_state = REPL_STATE_CONNECT;
@ -3042,8 +3042,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(REDICTMODULE_EVENT_MASTER_LINK_CHANGE,
REDICTMODULE_SUBEVENT_MASTER_LINK_DOWN,
NULL);
/* Clear masterhost first, since the freeClient calls
@ -3084,8 +3084,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(REDICTMODULE_EVENT_REPLICATION_ROLE_CHANGED,
REDICTMODULE_EVENT_REPLROLECHANGED_NOW_MASTER,
NULL);
/* Restart the AOF subsystem in case we shut it down during a sync when
@ -3098,8 +3098,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(REDICTMODULE_EVENT_MASTER_LINK_CHANGE,
REDICTMODULE_SUBEVENT_MASTER_LINK_DOWN,
NULL);
server.master = NULL;
@ -3387,8 +3387,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(REDICTMODULE_EVENT_MASTER_LINK_CHANGE,
REDICTMODULE_SUBEVENT_MASTER_LINK_UP,
NULL);
/* Re-add to the list of clients. */

View File

@ -655,8 +655,8 @@ void resetChildState(void) {
server.stat_current_save_keys_total = 0;
updateDictResizePolicy();
closeChildInfoPipe();
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
REDISMODULE_SUBEVENT_FORK_CHILD_DIED,
moduleFireServerEvent(REDICTMODULE_EVENT_FORK_CHILD,
REDICTMODULE_SUBEVENT_FORK_CHILD_DIED,
NULL);
}
@ -1501,8 +1501,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
}
/* Fire the cron loop modules event. */
RedictModuleCronLoopV1 ei = {REDISMODULE_CRON_LOOP_VERSION,server.hz};
moduleFireServerEvent(REDISMODULE_EVENT_CRON_LOOP,
RedictModuleCronLoopV1 ei = {REDICTMODULE_CRON_LOOP_VERSION,server.hz};
moduleFireServerEvent(REDICTMODULE_EVENT_CRON_LOOP,
0,
&ei);
@ -1664,8 +1664,8 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST);
if (moduleCount()) {
moduleFireServerEvent(REDISMODULE_EVENT_EVENTLOOP,
REDISMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP,
moduleFireServerEvent(REDICTMODULE_EVENT_EVENTLOOP,
REDICTMODULE_SUBEVENT_EVENTLOOP_BEFORE_SLEEP,
NULL);
}
@ -1794,8 +1794,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(REDICTMODULE_EVENT_EVENTLOOP,
REDICTMODULE_SUBEVENT_EVENTLOOP_AFTER_SLEEP,
NULL);
latencyEndMonitor(latency);
latencyAddSampleIfNeeded("module-acquire-GIL",latency);
@ -4480,7 +4480,7 @@ int finishShutdown(void) {
if (server.aof_manifest) aofManifestFree(server.aof_manifest);
/* Fire the shutdown modules event. */
moduleFireServerEvent(REDISMODULE_EVENT_SHUTDOWN,0,NULL);
moduleFireServerEvent(REDICTMODULE_EVENT_SHUTDOWN,0,NULL);
/* Remove the pid file if possible and needed. */
if (server.daemonize || server.pidfile) {
@ -6490,8 +6490,8 @@ int redictFork(int purpose) {
}
updateDictResizePolicy();
moduleFireServerEvent(REDISMODULE_EVENT_FORK_CHILD,
REDISMODULE_SUBEVENT_FORK_CHILD_BORN,
moduleFireServerEvent(REDICTMODULE_EVENT_FORK_CHILD,
REDICTMODULE_SUBEVENT_FORK_CHILD_BORN,
NULL);
}
return childpid;

View File

@ -58,7 +58,7 @@ typedef long long ustime_t; /* microsecond time type. */
#include "rax.h" /* Radix tree */
#include "connection.h" /* Connection abstraction */
#define REDISMODULE_CORE 1
#define REDICTMODULE_CORE 1
typedef struct redictObject robj;
#include "redictmodule.h" /* Redis modules API defines. */
@ -702,14 +702,14 @@ 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)-1)
#define REDISMODULE_TYPE_ENCVER(id) ((id) & REDISMODULE_TYPE_ENCVER_MASK)
#define REDISMODULE_TYPE_SIGN(id) (((id) & ~((uint64_t)REDISMODULE_TYPE_ENCVER_MASK)) >>REDISMODULE_TYPE_ENCVER_BITS)
#define REDICTMODULE_TYPE_ENCVER_BITS 10
#define REDICTMODULE_TYPE_ENCVER_MASK ((1<<REDICTMODULE_TYPE_ENCVER_BITS)-1)
#define REDICTMODULE_TYPE_ENCVER(id) ((id) & REDICTMODULE_TYPE_ENCVER_MASK)
#define REDICTMODULE_TYPE_SIGN(id) (((id) & ~((uint64_t)REDICTMODULE_TYPE_ENCVER_MASK)) >>REDICTMODULE_TYPE_ENCVER_BITS)
/* Bit flags for moduleTypeAuxSaveFunc */
#define REDISMODULE_AUX_BEFORE_RDB (1<<0)
#define REDISMODULE_AUX_AFTER_RDB (1<<1)
#define REDICTMODULE_AUX_BEFORE_RDB (1<<0)
#define REDICTMODULE_AUX_AFTER_RDB (1<<1)
struct RedictModule;
struct RedictModuleIO;
@ -1992,7 +1992,7 @@ struct redictServer {
int cluster_module_flags; /* Set of flags that Redict modules are able
to set in order to suppress certain
native Redict Cluster features. Check the
REDISMODULE_CLUSTER_FLAG_*. */
REDICTMODULE_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. */

View File

@ -5,7 +5,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-License-Identifier: LGPL-3.0-only
#define REDISMODULE_CORE_MODULE /* A module that's part of the redict core, uses server.h too. */
#define REDICTMODULE_CORE_MODULE /* A module that's part of the redict core, uses server.h too. */
#include "server.h"
#include "connhelpers.h"
@ -1156,29 +1156,29 @@ int RedictModule_OnLoad(void *ctx, RedictModuleString **argv, int argc) {
/* Connection modules must be part of the same build as redict. */
if (strcmp(REDICT_BUILD_ID_RAW, redisBuildIdRaw())) {
serverLog(LL_NOTICE, "Connection type %s was not built together with the redict-server used.", CONN_TYPE_TLS);
return REDISMODULE_ERR;
return REDICTMODULE_ERR;
}
if (RedictModule_Init(ctx,"tls",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
if (RedictModule_Init(ctx,"tls",1,REDICTMODULE_APIVER_1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
/* Connection modules is available only bootup. */
if ((RedictModule_GetContextFlags(ctx) & REDISMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) {
if ((RedictModule_GetContextFlags(ctx) & REDICTMODULE_CTX_FLAGS_SERVER_STARTUP) == 0) {
serverLog(LL_NOTICE, "Connection type %s can be loaded only during bootup", CONN_TYPE_TLS);
return REDISMODULE_ERR;
return REDICTMODULE_ERR;
}
RedictModule_SetModuleOptions(ctx, REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD);
RedictModule_SetModuleOptions(ctx, REDICTMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD);
if(connTypeRegister(&CT_TLS) != C_OK)
return REDISMODULE_ERR;
return REDICTMODULE_ERR;
return REDISMODULE_OK;
return REDICTMODULE_OK;
}
int RedictModule_OnUnload(void *arg) {
UNUSED(arg);
serverLog(LL_NOTICE, "Connection type %s can not be unloaded", CONN_TYPE_TLS);
return REDISMODULE_ERR;
return REDICTMODULE_ERR;
}
#endif