mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
tests/modules: fix remaining redis => redict cases
Non-API impacting renames. Signed-off-by: Drew DeVault <sir@cmpwn.com>
This commit is contained in:
parent
03d144a452
commit
cdd60793d5
@ -231,7 +231,7 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
if (argc > 1) return RedictModule_WrongArity(ctx);
|
||||
|
||||
/* When that flag is passed, we try to create too many categories,
|
||||
* and the test expects this to fail. In this case redis returns REDICTMODULE_ERR
|
||||
* and the test expects this to fail. In this case redict returns REDICTMODULE_ERR
|
||||
* and set errno to ENOMEM*/
|
||||
if (argc == 1) {
|
||||
long long fail_flag = 0;
|
||||
@ -294,14 +294,14 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
/* This validates that, when module tries to add a category with invalid characters,
|
||||
* redis returns REDICTMODULE_ERR and set errno to `EINVAL` */
|
||||
* redict returns REDICTMODULE_ERR and set errno to `EINVAL` */
|
||||
if (RedictModule_AddACLCategory(ctx,"!nval!dch@r@cter$") == REDICTMODULE_ERR)
|
||||
RedictModule_Assert(errno == EINVAL);
|
||||
else
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
/* This validates that, when module tries to add a category that already exists,
|
||||
* redis returns REDICTMODULE_ERR and set errno to `EBUSY` */
|
||||
* redict returns REDICTMODULE_ERR and set errno to `EBUSY` */
|
||||
if (RedictModule_AddACLCategory(ctx,"write") == REDICTMODULE_ERR)
|
||||
RedictModule_Assert(errno == EBUSY);
|
||||
else
|
||||
|
@ -226,8 +226,8 @@ int test_rm_register_blocking_auth_cb(RedictModuleCtx *ctx, RedictModuleString *
|
||||
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. */
|
||||
/* This function must be present on each Redict module. It is used in order to
|
||||
* register the commands into the Redict server. */
|
||||
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
REDICTMODULE_NOT_USED(argv);
|
||||
REDICTMODULE_NOT_USED(argc);
|
||||
|
@ -22,7 +22,7 @@ static volatile int g_slow_bg_operation = 0;
|
||||
static volatile int g_is_in_slow_bg_operation = 0;
|
||||
|
||||
void *sub_worker(void *arg) {
|
||||
// Get Redis module context
|
||||
// Get Redict module context
|
||||
RedictModuleCtx *ctx = (RedictModuleCtx *)arg;
|
||||
|
||||
// Try acquiring GIL
|
||||
@ -38,7 +38,7 @@ void *worker(void *arg) {
|
||||
// Retrieve blocked client
|
||||
RedictModuleBlockedClient *bc = (RedictModuleBlockedClient *)arg;
|
||||
|
||||
// Get Redis module context
|
||||
// Get Redict module context
|
||||
RedictModuleCtx *ctx = RedictModule_GetThreadSafeContext(bc);
|
||||
|
||||
// Acquire GIL
|
||||
@ -61,7 +61,7 @@ void *worker(void *arg) {
|
||||
// Unblock client
|
||||
RedictModule_UnblockClient(bc, NULL);
|
||||
|
||||
// Free the Redis module context
|
||||
// Free the Redict module context
|
||||
RedictModule_FreeThreadSafeContext(ctx);
|
||||
|
||||
return NULL;
|
||||
@ -110,7 +110,7 @@ void *bg_call_worker(void *arg) {
|
||||
bg_call_data *bg = arg;
|
||||
RedictModuleBlockedClient *bc = bg->bc;
|
||||
|
||||
// Get Redis module context
|
||||
// Get Redict module context
|
||||
RedictModuleCtx *ctx = RedictModule_GetThreadSafeContext(bg->bc);
|
||||
|
||||
// Acquire GIL
|
||||
@ -129,18 +129,18 @@ void *bg_call_worker(void *arg) {
|
||||
// Call the command
|
||||
const char *module_cmd = RedictModule_StringPtrLen(bg->argv[0], NULL);
|
||||
int cmd_pos = 1;
|
||||
RedictModuleString *format_redis_str = RedictModule_CreateString(NULL, "v", 1);
|
||||
RedictModuleString *format_redict_str = RedictModule_CreateString(NULL, "v", 1);
|
||||
if (!strcasecmp(module_cmd, "do_bg_rm_call_format")) {
|
||||
cmd_pos = 2;
|
||||
size_t format_len;
|
||||
const char *format = RedictModule_StringPtrLen(bg->argv[1], &format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redis_str, format, format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redis_str, "E", 1);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redict_str, format, format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redict_str, "E", 1);
|
||||
}
|
||||
const char *format = RedictModule_StringPtrLen(format_redis_str, NULL);
|
||||
const char *format = RedictModule_StringPtrLen(format_redict_str, NULL);
|
||||
const char *cmd = RedictModule_StringPtrLen(bg->argv[cmd_pos], NULL);
|
||||
RedictModuleCallReply *rep = RedictModule_Call(ctx, cmd, format, bg->argv + cmd_pos + 1, bg->argc - cmd_pos - 1);
|
||||
RedictModule_FreeString(NULL, format_redis_str);
|
||||
RedictModule_FreeString(NULL, format_redict_str);
|
||||
|
||||
/* Free the arguments within GIL to prevent simultaneous freeing in main thread. */
|
||||
for (int i=0; i<bg->argc; i++)
|
||||
@ -162,7 +162,7 @@ void *bg_call_worker(void *arg) {
|
||||
// Unblock client
|
||||
RedictModule_UnblockClient(bc, NULL);
|
||||
|
||||
// Free the Redis module context
|
||||
// Free the Redict module context
|
||||
RedictModule_FreeThreadSafeContext(ctx);
|
||||
|
||||
return NULL;
|
||||
@ -622,7 +622,7 @@ static void timer_callback(RedictModuleCtx *ctx, void *data)
|
||||
|
||||
RedictModuleBlockedClient *bc = data;
|
||||
|
||||
// Get Redis module context
|
||||
// Get Redict module context
|
||||
RedictModuleCtx *reply_ctx = RedictModule_GetThreadSafeContext(bc);
|
||||
|
||||
// Reply to client
|
||||
@ -631,7 +631,7 @@ static void timer_callback(RedictModuleCtx *ctx, void *data)
|
||||
// Unblock client
|
||||
RedictModule_UnblockClient(bc, NULL);
|
||||
|
||||
// Free the Redis module context
|
||||
// Free the Redict module context
|
||||
RedictModule_FreeThreadSafeContext(reply_ctx);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ void HelloBlock_Disconnected(RedictModuleCtx *ctx, RedictModuleBlockedClient *bc
|
||||
/* BLOCK.DEBUG <delay_ms> <timeout_ms> -- Block for <count> milliseconds, then reply with
|
||||
* a random number. Timeout is the command timeout, so that you can test
|
||||
* what happens when the delay is greater than the timeout. */
|
||||
int HelloBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int HelloBlock_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (argc != 3) return RedictModule_WrongArity(ctx);
|
||||
long long delay;
|
||||
long long timeout;
|
||||
@ -172,7 +172,7 @@ int HelloBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
|
||||
* a random number. Timeout is the command timeout, so that you can test
|
||||
* what happens when the delay is greater than the timeout.
|
||||
* this command does not track background time so the background time should no appear in stats*/
|
||||
int HelloBlockNoTracking_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int HelloBlockNoTracking_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (argc != 3) return RedictModule_WrongArity(ctx);
|
||||
long long delay;
|
||||
long long timeout;
|
||||
@ -214,7 +214,7 @@ int HelloBlockNoTracking_RedisCommand(RedictModuleCtx *ctx, RedictModuleString *
|
||||
* then reply with a random number.
|
||||
* This command is used to test multiple calls to RedictModule_BlockedClientMeasureTimeStart()
|
||||
* and RedictModule_BlockedClientMeasureTimeEnd() within the same execution. */
|
||||
int HelloDoubleBlock_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int HelloDoubleBlock_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (argc != 2) return RedictModule_WrongArity(ctx);
|
||||
long long delay;
|
||||
|
||||
@ -246,7 +246,7 @@ RedictModuleBlockedClient *blocked_client = NULL;
|
||||
* or TIMEOUT seconds. If TIMEOUT is zero, no timeout function is
|
||||
* registered.
|
||||
*/
|
||||
int Block_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int Block_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (RedictModule_IsBlockedReplyRequest(ctx)) {
|
||||
RedictModuleString *r = RedictModule_GetBlockedClientPrivateData(ctx);
|
||||
return RedictModule_ReplyWithString(ctx, r);
|
||||
@ -269,14 +269,14 @@ int Block_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc
|
||||
/* Block client. We use this function as both a reply and optional timeout
|
||||
* callback and differentiate the different code flows above.
|
||||
*/
|
||||
blocked_client = RedictModule_BlockClient(ctx, Block_RedisCommand,
|
||||
timeout > 0 ? Block_RedisCommand : NULL, HelloBlock_FreeStringData, timeout);
|
||||
blocked_client = RedictModule_BlockClient(ctx, Block_RedictCommand,
|
||||
timeout > 0 ? Block_RedictCommand : NULL, HelloBlock_FreeStringData, timeout);
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
/* BLOCK.IS_BLOCKED -- Returns 1 if we have a blocked client, or 0 otherwise.
|
||||
*/
|
||||
int IsBlocked_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int IsBlocked_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
UNUSED(argv);
|
||||
UNUSED(argc);
|
||||
RedictModule_ReplyWithLongLong(ctx, blocked_client ? 1 : 0);
|
||||
@ -285,7 +285,7 @@ int IsBlocked_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
|
||||
|
||||
/* BLOCK.RELEASE [reply] -- Releases the blocked client and produce the specified reply.
|
||||
*/
|
||||
int Release_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int Release_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (argc != 2) return RedictModule_WrongArity(ctx);
|
||||
if (!blocked_client) {
|
||||
return RedictModule_ReplyWithError(ctx, "ERR No blocked client");
|
||||
@ -309,27 +309,27 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"block.debug",
|
||||
HelloBlock_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
HelloBlock_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"block.double_debug",
|
||||
HelloDoubleBlock_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
HelloDoubleBlock_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"block.debug_no_track",
|
||||
HelloBlockNoTracking_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
HelloBlockNoTracking_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "block.block",
|
||||
Block_RedisCommand, "", 0, 0, 0) == REDICTMODULE_ERR)
|
||||
Block_RedictCommand, "", 0, 0, 0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"block.is_blocked",
|
||||
IsBlocked_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
IsBlocked_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"block.release",
|
||||
Release_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
Release_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
return REDICTMODULE_OK;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define LIST_SIZE 1024
|
||||
|
||||
/* The FSL (Fixed-Size List) data type is a low-budget imitation of the
|
||||
* native Redis list, in order to test list-like commands implemented
|
||||
* native Redict list, in order to test list-like commands implemented
|
||||
* by a module.
|
||||
* Examples: FSL.PUSH, FSL.BPOP, etc. */
|
||||
|
||||
|
@ -35,7 +35,7 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
.tips = "nondeterministic_output",
|
||||
.history = (RedictModuleCommandHistoryEntry[]){
|
||||
/* NOTE: All versions specified should be the module's versions, not
|
||||
* Redis'! We use Redis versions in this example for the purpose of
|
||||
* Redict'! We use Redict versions in this example for the purpose of
|
||||
* testing (comparing the output with the output of the vanilla
|
||||
* XADD). */
|
||||
{"6.2.0", "Added the `NOMKSTREAM` option, `MINID` trimming strategy and the `LIMIT` option."},
|
||||
|
@ -51,7 +51,7 @@
|
||||
* dict
|
||||
*
|
||||
*
|
||||
* Keys in redis database:
|
||||
* Keys in redict database:
|
||||
*
|
||||
* ┌───────┐
|
||||
* │ size │
|
||||
@ -70,7 +70,7 @@
|
||||
* │ k3 │ ───┼─┐ │ k2 │ ───┼─┐
|
||||
* │ │ │ │ │ │ │ │
|
||||
* └─────┴─────┘ │ ┌───────┐ └─────┴─────┘ │ ┌───────┐
|
||||
* redis db[0] │ │ size │ redis db[1] │ │ size │
|
||||
* redict db[0] │ │ size │ redict db[1]│ │ size │
|
||||
* └───────────►│ used │ └───────────►│ used │
|
||||
* │ mask │ │ mask │
|
||||
* └───────┘ └───────┘
|
||||
@ -242,7 +242,7 @@ void flushdbCallback(RedictModuleCtx *ctx, RedictModuleEvent e, uint64_t sub, vo
|
||||
/*---------------------------- command implementation ------------------------------------*/
|
||||
|
||||
/* MEM.ALLOC key block_num */
|
||||
int MemAlloc_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemAlloc_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc != 3) {
|
||||
@ -281,7 +281,7 @@ int MemAlloc_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int a
|
||||
}
|
||||
|
||||
/* MEM.FREE key */
|
||||
int MemFree_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemFree_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc != 2) {
|
||||
@ -320,7 +320,7 @@ int MemFree_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int ar
|
||||
}
|
||||
|
||||
/* MEM.WRITE key block_index data */
|
||||
int MemWrite_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemWrite_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc != 4) {
|
||||
@ -366,7 +366,7 @@ int MemWrite_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int a
|
||||
}
|
||||
|
||||
/* MEM.READ key block_index */
|
||||
int MemRead_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemRead_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc != 3) {
|
||||
@ -408,7 +408,7 @@ int MemRead_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int ar
|
||||
}
|
||||
|
||||
/* MEM.USAGE dbid */
|
||||
int MemUsage_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemUsage_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc != 2) {
|
||||
@ -453,7 +453,7 @@ int MemUsage_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int a
|
||||
}
|
||||
|
||||
/* MEM.ALLOCANDWRITE key block_num block_index data block_index data ... */
|
||||
int MemAllocAndWrite_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int MemAllocAndWrite_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx);
|
||||
|
||||
if (argc < 3) {
|
||||
@ -709,28 +709,28 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "mem.alloc", MemAlloc_RedisCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.alloc", MemAlloc_RedictCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "mem.free", MemFree_RedisCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.free", MemFree_RedictCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "mem.write", MemWrite_RedisCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.write", MemWrite_RedictCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "mem.read", MemRead_RedisCommand, "readonly", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.read", MemRead_RedictCommand, "readonly", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
if (RedictModule_CreateCommand(ctx, "mem.usage", MemUsage_RedisCommand, "readonly", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.usage", MemUsage_RedictCommand, "readonly", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
/* used for internal aof rewrite */
|
||||
if (RedictModule_CreateCommand(ctx, "mem.allocandwrite", MemAllocAndWrite_RedisCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
if (RedictModule_CreateCommand(ctx, "mem.allocandwrite", MemAllocAndWrite_RedictCommand, "write deny-oom", 1, 1, 1) == REDICTMODULE_ERR) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ int fork_create(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
|
||||
}
|
||||
|
||||
if(!RMAPI_FUNC_SUPPORTED(RedictModule_Fork)){
|
||||
RedictModule_ReplyWithError(ctx, "Fork api is not supported in the current redis version");
|
||||
RedictModule_ReplyWithError(ctx, "Fork api is not supported in the current redict version");
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
|
||||
|
@ -375,8 +375,8 @@ static int cmdKeyExpiry(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
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. */
|
||||
/* This function must be present on each Redict module. It is used in order to
|
||||
* register the commands into the Redict server. */
|
||||
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
#define VerifySubEventSupported(e, s) \
|
||||
if (!RedictModule_IsSubEventSupported(e, s)) { \
|
||||
|
@ -110,16 +110,16 @@ static int KeySpace_NotificationModuleKeyMiss(RedictModuleCtx *ctx, int type, co
|
||||
static int KeySpace_NotificationModuleString(RedictModuleCtx *ctx, int type, const char *event, RedictModuleString *key) {
|
||||
REDICTMODULE_NOT_USED(type);
|
||||
REDICTMODULE_NOT_USED(event);
|
||||
RedictModuleKey *redis_key = RedictModule_OpenKey(ctx, key, REDICTMODULE_READ);
|
||||
RedictModuleKey *redict_key = RedictModule_OpenKey(ctx, key, REDICTMODULE_READ);
|
||||
|
||||
size_t len = 0;
|
||||
/* RedictModule_StringDMA could change the data format and cause the old robj to be freed.
|
||||
* This code verifies that such format change will not cause any crashes.*/
|
||||
char *data = RedictModule_StringDMA(redis_key, &len, REDICTMODULE_READ);
|
||||
char *data = RedictModule_StringDMA(redict_key, &len, REDICTMODULE_READ);
|
||||
int res = strncmp(data, "dummy", 5);
|
||||
REDICTMODULE_NOT_USED(res);
|
||||
|
||||
RedictModule_CloseKey(redis_key);
|
||||
RedictModule_CloseKey(redict_key);
|
||||
|
||||
return REDICTMODULE_OK;
|
||||
}
|
||||
@ -291,8 +291,8 @@ static int cmdGetDels(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
|
||||
return RedictModule_ReplyWithLongLong(ctx, dels);
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
/* This function must be present on each Redict module. It is used in order to
|
||||
* register the commands into the Redict server. */
|
||||
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
if (RedictModule_Init(ctx,"testkeyspace",1,REDICTMODULE_APIVER_1) == REDICTMODULE_ERR){
|
||||
return REDICTMODULE_ERR;
|
||||
|
@ -219,8 +219,8 @@ static void KeySpace_ServerEventCallback(RedictModuleCtx *ctx, RedictModuleEvent
|
||||
if (res == REDICTMODULE_ERR) KeySpace_ServerEventPostNotificationFree(pn_ctx);
|
||||
}
|
||||
|
||||
/* This function must be present on each Redis module. It is used in order to
|
||||
* register the commands into the Redis server. */
|
||||
/* This function must be present on each Redict module. It is used in order to
|
||||
* register the commands into the Redict server. */
|
||||
int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
REDICTMODULE_NOT_USED(argv);
|
||||
REDICTMODULE_NOT_USED(argc);
|
||||
|
@ -127,7 +127,7 @@ void timerHandlerEval(RedictModuleCtx *ctx, void *data) {
|
||||
|
||||
RedictModuleCallReply *reply = RedictModule_Call(ctx,"INCRBY","cc!","timer-eval-start","1");
|
||||
RedictModule_FreeCallReply(reply);
|
||||
reply = RedictModule_Call(ctx, "EVAL", "cccc!", "redis.call('set',KEYS[1],ARGV[1])", "1", "foo", "bar");
|
||||
reply = RedictModule_Call(ctx, "EVAL", "cccc!", "redict.call('set',KEYS[1],ARGV[1])", "1", "foo", "bar");
|
||||
RedictModule_FreeCallReply(reply);
|
||||
|
||||
RedictModule_Replicate(ctx, "INCR", "c", "timer-eval-middle");
|
||||
|
@ -64,7 +64,7 @@ void LazyFreeLinkReleaseObject(struct LazyFreeLinkObject *o) {
|
||||
}
|
||||
|
||||
/* LAZYFREELINK.INSERT key value */
|
||||
int LazyFreeLinkInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int LazyFreeLinkInsert_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
|
||||
|
||||
if (argc != 3) return RedictModule_WrongArity(ctx);
|
||||
@ -99,7 +99,7 @@ int LazyFreeLinkInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **a
|
||||
}
|
||||
|
||||
/* LAZYFREELINK.LEN key */
|
||||
int LazyFreeLinkLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
int LazyFreeLinkLen_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
|
||||
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
|
||||
|
||||
if (argc != 2) return RedictModule_WrongArity(ctx);
|
||||
@ -172,7 +172,7 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
if (RedictModule_Init(ctx,"lazyfreetest",1,REDICTMODULE_APIVER_1)
|
||||
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
|
||||
|
||||
/* We only allow our module to be loaded when the redis core version is greater than the version of my module */
|
||||
/* We only allow our module to be loaded when the Redict core version is greater than the version of my module */
|
||||
if (RedictModule_GetTypeMethodVersion() < REDICTMODULE_TYPE_METHOD_VERSION) {
|
||||
return REDICTMODULE_ERR;
|
||||
}
|
||||
@ -191,11 +191,11 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
|
||||
if (LazyFreeLinkType == NULL) return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"lazyfreelink.insert",
|
||||
LazyFreeLinkInsert_RedisCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
|
||||
LazyFreeLinkInsert_RedictCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
if (RedictModule_CreateCommand(ctx,"lazyfreelink.len",
|
||||
LazyFreeLinkLen_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
|
||||
LazyFreeLinkLen_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
|
||||
return REDICTMODULE_ERR;
|
||||
|
||||
return REDICTMODULE_OK;
|
||||
|
@ -123,7 +123,7 @@ void *bg_call_worker(void *arg) {
|
||||
bg_call_data *bg = arg;
|
||||
RedictModuleBlockedClient *bc = bg->bc;
|
||||
|
||||
// Get Redis module context
|
||||
// Get Redict module context
|
||||
RedictModuleCtx *ctx = RedictModule_GetThreadSafeContext(bg->bc);
|
||||
|
||||
// Acquire GIL
|
||||
@ -134,14 +134,14 @@ void *bg_call_worker(void *arg) {
|
||||
|
||||
// Call the command
|
||||
size_t format_len;
|
||||
RedictModuleString *format_redis_str = RedictModule_CreateString(NULL, "v", 1);
|
||||
RedictModuleString *format_redict_str = RedictModule_CreateString(NULL, "v", 1);
|
||||
const char *format = RedictModule_StringPtrLen(bg->argv[1], &format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redis_str, format, format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redis_str, "E", 1);
|
||||
format = RedictModule_StringPtrLen(format_redis_str, NULL);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redict_str, format, format_len);
|
||||
RedictModule_StringAppendBuffer(NULL, format_redict_str, "E", 1);
|
||||
format = RedictModule_StringPtrLen(format_redict_str, NULL);
|
||||
const char *cmd = RedictModule_StringPtrLen(bg->argv[2], NULL);
|
||||
RedictModuleCallReply *rep = RedictModule_Call(ctx, cmd, format, bg->argv + 3, bg->argc - 3);
|
||||
RedictModule_FreeString(NULL, format_redis_str);
|
||||
RedictModule_FreeString(NULL, format_redict_str);
|
||||
|
||||
/* Free the arguments within GIL to prevent simultaneous freeing in main thread. */
|
||||
for (int i=0; i<bg->argc; i++)
|
||||
@ -163,7 +163,7 @@ void *bg_call_worker(void *arg) {
|
||||
// Unblock client
|
||||
RedictModule_UnblockClient(bc, NULL);
|
||||
|
||||
// Free the Redis module context
|
||||
// Free the Redict module context
|
||||
RedictModule_FreeThreadSafeContext(ctx);
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user