src/modules: s/redis/redict/g

Final pass on these

Signed-off-by: Drew DeVault <sir@cmpwn.com>
This commit is contained in:
Drew DeVault 2024-03-26 10:59:57 +01:00
parent d4622e0592
commit a91d1148cf
8 changed files with 92 additions and 92 deletions

View File

@ -12,9 +12,9 @@
static RedictModuleUser *global;
static uint64_t global_auth_client_id = 0;
/* HELLOACL.REVOKE
/* HELLOACL.REVOKE
* Synchronously revoke access from a user. */
int RevokeCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int RevokeCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -22,13 +22,13 @@ int RevokeCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
RedictModule_DeauthenticateAndCloseClient(ctx, global_auth_client_id);
return RedictModule_ReplyWithSimpleString(ctx, "OK");
} else {
return RedictModule_ReplyWithError(ctx, "Global user currently not used");
return RedictModule_ReplyWithError(ctx, "Global user currently not used");
}
}
/* HELLOACL.RESET
/* HELLOACL.RESET
* Synchronously delete and re-create a module user. */
int ResetCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int ResetCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -41,7 +41,7 @@ int ResetCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
return RedictModule_ReplyWithSimpleString(ctx, "OK");
}
/* Callback handler for user changes, use this to notify a module of
/* 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) {
REDICTMODULE_NOT_USED(privdata);
@ -49,14 +49,14 @@ void HelloACL_UserChanged(uint64_t client_id, void *privdata) {
global_auth_client_id = 0;
}
/* HELLOACL.AUTHGLOBAL
/* HELLOACL.AUTHGLOBAL
* Synchronously assigns a module user to the current context. */
int AuthGlobalCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int AuthGlobalCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
if (global_auth_client_id) {
return RedictModule_ReplyWithError(ctx, "Global user currently used");
return RedictModule_ReplyWithError(ctx, "Global user currently used");
}
RedictModule_AuthenticateClientWithUser(ctx, global, HelloACL_UserChanged, NULL, &global_auth_client_id);
@ -75,9 +75,9 @@ int HelloACL_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModuleString *user_string = RedictModule_GetBlockedClientPrivateData(ctx);
const char *name = RedictModule_StringPtrLen(user_string, &length);
if (RedictModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) ==
if (RedictModule_AuthenticateClientWithACLUser(ctx, name, length, NULL, NULL, NULL) ==
REDICTMODULE_ERR) {
return RedictModule_ReplyWithError(ctx, "Invalid Username or password");
return RedictModule_ReplyWithError(ctx, "Invalid Username or password");
}
return RedictModule_ReplyWithSimpleString(ctx, "OK");
}
@ -106,14 +106,14 @@ void *HelloACL_ThreadMain(void *args) {
return NULL;
}
/* HELLOACL.AUTHASYNC
/* HELLOACL.AUTHASYNC
* Asynchronously assigns an ACL user to the current context. */
int AuthAsyncCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int AuthAsyncCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 2) return RedictModule_WrongArity(ctx);
pthread_t tid;
RedictModuleBlockedClient *bc = RedictModule_BlockClient(ctx, HelloACL_Reply, HelloACL_Timeout, HelloACL_FreeData, TIMEOUT_TIME);
void **targs = RedictModule_Alloc(sizeof(void*)*2);
targs[0] = bc;
@ -127,8 +127,8 @@ int AuthAsyncCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **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) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -137,19 +137,19 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.reset",
ResetCommand_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
ResetCommand_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.revoke",
RevokeCommand_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
RevokeCommand_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.authglobal",
AuthGlobalCommand_RedisCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
AuthGlobalCommand_RedictCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"helloacl.authasync",
AuthAsyncCommand_RedisCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
AuthAsyncCommand_RedictCommand,"no-auth",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
global = RedictModule_CreateModuleUser("global");

View File

@ -66,7 +66,7 @@ void HelloBlock_Disconnected(RedictModuleCtx *ctx, RedictModuleBlockedClient *bc
/* HELLO.BLOCK <delay> <timeout> -- Block for <count> seconds, then reply with
* a random number. Timeout is the command timeout, so that you can test
* what happens when the delay is greater than the timeout. */
int HelloBlock_RedisCommand(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;
@ -150,7 +150,7 @@ void *HelloKeys_ThreadMain(void *arg) {
* the server. The keys do not represent a point-in-time state so only the keys
* that were in the database from the start to the end are guaranteed to be
* there. */
int HelloKeys_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloKeys_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
if (argc != 1) return RedictModule_WrongArity(ctx);
@ -171,8 +171,8 @@ int HelloKeys_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
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);
@ -181,10 +181,10 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.block",
HelloBlock_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
HelloBlock_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.keys",
HelloKeys_RedisCommand,"",0,0,0) == REDICTMODULE_ERR)
HelloKeys_RedictCommand,"",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDICTMODULE_OK;

View File

@ -14,7 +14,7 @@
#define MSGTYPE_PONG 2
/* HELLOCLUSTER.PINGALL */
int PingallCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int PingallCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -23,7 +23,7 @@ int PingallCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
}
/* HELLOCLUSTER.LIST */
int ListCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int ListCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -60,8 +60,8 @@ void PongReceiver(RedictModuleCtx *ctx, const char *sender_id, uint8_t type, con
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. */
/* 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);
@ -70,14 +70,14 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellocluster.pingall",
PingallCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
PingallCommand_RedictCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellocluster.list",
ListCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
ListCommand_RedictCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
/* Disable Redis Cluster sharding and redirections. This way every node
/* Disable Redict Cluster sharding and redirections. This way every node
* will be able to access every possible key, regardless of the hash slot.
* This way the PING message handler will be able to increment a specific
* variable. Normally you do that in order for the distributed system

View File

@ -74,8 +74,8 @@ int cmd_KEYRANGE(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
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);

View File

@ -49,8 +49,8 @@ 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. */
/* 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);

View File

@ -18,7 +18,7 @@ void timerHandler(RedictModuleCtx *ctx, void *data) {
}
/* HELLOTIMER.TIMER*/
int TimerCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int TimerCommand_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -32,8 +32,8 @@ int TimerCommand_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
return RedictModule_ReplyWithSimpleString(ctx, "OK");
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
/* 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);
@ -42,7 +42,7 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotimer.timer",
TimerCommand_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
TimerCommand_RedictCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDICTMODULE_OK;

View File

@ -69,7 +69,7 @@ void HelloTypeReleaseObject(struct HelloTypeObject *o) {
/* ========================= "hellotype" type commands ======================= */
/* HELLOTYPE.INSERT key value */
int HelloTypeInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloTypeInsert_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 3) return RedictModule_WrongArity(ctx);
@ -106,7 +106,7 @@ int HelloTypeInsert_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
}
/* HELLOTYPE.RANGE key first count */
int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloTypeRange_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 4) return RedictModule_WrongArity(ctx);
@ -142,7 +142,7 @@ int HelloTypeRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
}
/* HELLOTYPE.LEN key */
int HelloTypeLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloTypeLen_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 2) return RedictModule_WrongArity(ctx);
@ -182,7 +182,7 @@ int HelloBlock_Reply(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
/* In case the key is able to serve our blocked client, let's directly
* use our original command implementation to make this example simpler. */
RedictModule_CloseKey(key);
return HelloTypeRange_RedisCommand(ctx,argv,argc-1);
return HelloTypeRange_RedictCommand(ctx,argv,argc-1);
}
/* Timeout callback for blocking command HELLOTYPE.BRANGE */
@ -201,7 +201,7 @@ void HelloBlock_FreeData(RedictModuleCtx *ctx, void *privdata) {
/* HELLOTYPE.BRANGE key first count timeout -- This is a blocking version of
* the RANGE operation, in order to show how to use the API
* RedictModule_BlockClientOnKeys(). */
int HelloTypeBRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloTypeBRange_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 5) return RedictModule_WrongArity(ctx);
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
@ -223,7 +223,7 @@ int HelloTypeBRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
/* Can we serve the reply synchronously? */
if (type != REDICTMODULE_KEYTYPE_EMPTY) {
return HelloTypeRange_RedisCommand(ctx,argv,argc-1);
return HelloTypeRange_RedictCommand(ctx,argv,argc-1);
}
/* Otherwise let's block on the key. */
@ -289,8 +289,8 @@ void HelloTypeDigest(RedictModuleDigest *md, void *value) {
RedictModule_DigestEndSequence(md);
}
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
/* 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);
@ -312,19 +312,19 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
if (HelloType == NULL) return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.insert",
HelloTypeInsert_RedisCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
HelloTypeInsert_RedictCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.range",
HelloTypeRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
HelloTypeRange_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.len",
HelloTypeLen_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
HelloTypeLen_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hellotype.brange",
HelloTypeBRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
HelloTypeBRange_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDICTMODULE_OK;

View File

@ -12,10 +12,10 @@
/* HELLO.SIMPLE is among the simplest commands you can implement.
* It just returns the currently selected DB id, a functionality which is
* missing in Redis. The command uses two important API calls: one to
* missing in Redict. The command uses two important API calls: one to
* fetch the currently selected DB, the other in order to send the client
* an integer reply as response. */
int HelloSimple_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloSimple_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
RedictModule_ReplyWithLongLong(ctx,RedictModule_GetSelectedDb(ctx));
@ -28,7 +28,7 @@ int HelloSimple_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, in
*
* You'll find this command to be roughly as fast as the actual RPUSH
* command. */
int HelloPushNative_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
int HelloPushNative_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
if (argc != 3) return RedictModule_WrongArity(ctx);
@ -43,11 +43,11 @@ int HelloPushNative_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
}
/* HELLO.PUSH.CALL implements RPUSH using an higher level approach, calling
* a Redis command instead of working with the key in a low level way. This
* approach is useful when you need to call Redis commands that are not
* a Redict command instead of working with the key in a low level way. This
* approach is useful when you need to call Redict commands that are not
* available as low level APIs, or when you don't need the maximum speed
* possible but instead prefer implementation simplicity. */
int HelloPushCall_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
int HelloPushCall_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
if (argc != 3) return RedictModule_WrongArity(ctx);
@ -63,7 +63,7 @@ int HelloPushCall_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
/* HELLO.PUSH.CALL2
* This is exactly as HELLO.PUSH.CALL, but shows how we can reply to the
* client using directly a reply object that Call() returned. */
int HelloPushCall2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
int HelloPushCall2_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
if (argc != 3) return RedictModule_WrongArity(ctx);
@ -76,9 +76,9 @@ int HelloPushCall2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
}
/* HELLO.LIST.SUM.LEN returns the total length of all the items inside
* a Redis list, by using the high level Call() API.
* a Redict list, by using the high level Call() API.
* This command is an example of the array reply access. */
int HelloListSumLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
int HelloListSumLen_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
if (argc != 2) return RedictModule_WrongArity(ctx);
@ -101,7 +101,7 @@ int HelloListSumLen_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
* Moves 'count' elements from the tail of 'srclist' to the head of
* 'dstlist'. If less than count elements are available, it moves as much
* elements as possible. */
int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloListSplice_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 4) return RedictModule_WrongArity(ctx);
RedictModuleKey *srckey = RedictModule_OpenKey(ctx,argv[1],
@ -146,7 +146,7 @@ int HelloListSplice_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
/* Like the HELLO.LIST.SPLICE above, but uses automatic memory management
* in order to avoid freeing stuff. */
int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloListSpliceAuto_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 4) return RedictModule_WrongArity(ctx);
RedictModule_AutoMemory(ctx);
@ -188,7 +188,7 @@ int HelloListSpliceAuto_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **
/* HELLO.RAND.ARRAY <count>
* Shows how to generate arrays as commands replies.
* It just outputs <count> random numbers. */
int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloRandArray_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 2) return RedictModule_WrongArity(ctx);
long long count;
if (RedictModule_StringToLongLong(argv[1],&count) != REDICTMODULE_OK ||
@ -207,7 +207,7 @@ int HelloRandArray_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
* in the RedictModule_Call() call, the two INCRs get replicated.
* Also note how the ECHO is replicated in an unexpected position (check
* comments the function implementation). */
int HelloRepl1_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
int HelloRepl1_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc)
{
REDICTMODULE_NOT_USED(argv);
REDICTMODULE_NOT_USED(argc);
@ -245,7 +245,7 @@ int HelloRepl1_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
* as reply.
*
* Usage: HELLO.REPL2 <list-key> */
int HelloRepl2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloRepl2_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 2) return RedictModule_WrongArity(ctx);
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
@ -281,7 +281,7 @@ int HelloRepl2_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
* of variety).
*
* HELLO.TOGGLE.CASE key */
int HelloToggleCase_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloToggleCase_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
if (argc != 2) return RedictModule_WrongArity(ctx);
RedictModuleKey *key = RedictModule_OpenKey(ctx,argv[1],
@ -317,7 +317,7 @@ int HelloToggleCase_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
*
* If the key has already an associated TTL, extends it by "milliseconds"
* milliseconds. Otherwise no operation is performed. */
int HelloMoreExpire_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloMoreExpire_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 3) return RedictModule_WrongArity(ctx);
@ -342,7 +342,7 @@ int HelloMoreExpire_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv
* The computation is performed two times, one time from start to end and
* another time backward. The two scores, returned as a two element array,
* should match.*/
int HelloZsumRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloZsumRange_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
double score_start, score_end;
if (argc != 4) return RedictModule_WrongArity(ctx);
@ -397,7 +397,7 @@ int HelloZsumRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
* The command will return all the sorted set items that are lexicographically
* between the specified range (using the same format as ZRANGEBYLEX)
* and having an age between min_age and max_age. */
int HelloLexRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloLexRange_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 6) return RedictModule_WrongArity(ctx);
@ -435,7 +435,7 @@ int HelloLexRange_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv,
*
* The command returns 1 if the copy is performed (srcfield exists) otherwise
* 0 is returned. */
int HelloHCopy_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloHCopy_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
if (argc != 4) return RedictModule_WrongArity(ctx);
@ -462,7 +462,7 @@ int HelloHCopy_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
* This is an implementation of the infamous LEFTPAD function, that
* was at the center of an issue with the npm modules system in March 2016.
*
* LEFTPAD is a good example of using a Redis Modules API called
* LEFTPAD is a good example of using a Redict Modules API called
* "pool allocator", that was a famous way to allocate memory in yet another
* open source project, the Apache web server.
*
@ -476,7 +476,7 @@ int HelloHCopy_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int
*
* Note that PoolAlloc() does not necessarily require AutoMemory to be
* active. */
int HelloLeftPad_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
int HelloLeftPad_RedictCommand(RedictModuleCtx *ctx, RedictModuleString **argv, int argc) {
RedictModule_AutoMemory(ctx); /* Use automatic memory management. */
long long padlen;
@ -510,8 +510,8 @@ int HelloLeftPad_RedisCommand(RedictModuleCtx *ctx, RedictModuleString **argv, i
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) {
if (RedictModule_Init(ctx,"helloworld",1,REDICTMODULE_APIVER_1)
== REDICTMODULE_ERR) return REDICTMODULE_ERR;
@ -523,68 +523,68 @@ int RedictModule_OnLoad(RedictModuleCtx *ctx, RedictModuleString **argv, int arg
}
if (RedictModule_CreateCommand(ctx,"hello.simple",
HelloSimple_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
HelloSimple_RedictCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.push.native",
HelloPushNative_RedisCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
HelloPushNative_RedictCommand,"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) == REDICTMODULE_ERR)
HelloPushCall_RedictCommand,"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) == REDICTMODULE_ERR)
HelloPushCall2_RedictCommand,"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) == REDICTMODULE_ERR)
HelloListSumLen_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.list.splice",
HelloListSplice_RedisCommand,"write deny-oom",1,2,1) == REDICTMODULE_ERR)
HelloListSplice_RedictCommand,"write deny-oom",1,2,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.list.splice.auto",
HelloListSpliceAuto_RedisCommand,
HelloListSpliceAuto_RedictCommand,
"write deny-oom",1,2,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.rand.array",
HelloRandArray_RedisCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
HelloRandArray_RedictCommand,"readonly",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.repl1",
HelloRepl1_RedisCommand,"write",0,0,0) == REDICTMODULE_ERR)
HelloRepl1_RedictCommand,"write",0,0,0) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.repl2",
HelloRepl2_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
HelloRepl2_RedictCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.toggle.case",
HelloToggleCase_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
HelloToggleCase_RedictCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.more.expire",
HelloMoreExpire_RedisCommand,"write",1,1,1) == REDICTMODULE_ERR)
HelloMoreExpire_RedictCommand,"write",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.zsumrange",
HelloZsumRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
HelloZsumRange_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.lexrange",
HelloLexRange_RedisCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
HelloLexRange_RedictCommand,"readonly",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.hcopy",
HelloHCopy_RedisCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
HelloHCopy_RedictCommand,"write deny-oom",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
if (RedictModule_CreateCommand(ctx,"hello.leftpad",
HelloLeftPad_RedisCommand,"",1,1,1) == REDICTMODULE_ERR)
HelloLeftPad_RedictCommand,"",1,1,1) == REDICTMODULE_ERR)
return REDICTMODULE_ERR;
return REDICTMODULE_OK;