From 6ef6582695c83b3802f551bda3b00a526357c1b3 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Thu, 21 Mar 2024 15:58:44 -0500 Subject: [PATCH 1/5] fix typo in API.md --- API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 9831ecc..81a220d 100644 --- a/API.md +++ b/API.md @@ -3,8 +3,8 @@ Redis Modules: an introduction to the API The modules documentation is composed of the following files: -* `INTRO.md` (this file). An overview about Redis Modules system and API. It's a good idea to start your reading here. -* `API.md` is generated from module.c top comments of RedisMoule functions. It is a good reference in order to understand how each function works. +* `API.md` (this file). An overview about Redis Modules system and API. It's a good idea to start your reading here. +* `FUNCTIONS.md` is generated from module.c top comments of RedisMoule functions. It is a good reference in order to understand how each function works. * `TYPES.md` covers the implementation of native data types into modules. * `BLOCK.md` shows how to write blocking commands that will not reply immediately, but will block the client, without blocking the Redis server, and will provide a reply whenever will be possible. From 45668d793dd733d5eff36d90425e044ac0505272 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Fri, 22 Mar 2024 10:46:12 -0500 Subject: [PATCH 2/5] fix typo in BLOCK.md --- BLOCK.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BLOCK.md b/BLOCK.md index d4f3c93..cb2831d 100644 --- a/BLOCK.md +++ b/BLOCK.md @@ -87,7 +87,7 @@ int his command, in order to take the example simple. RedisModule_UnblockClient(bc,NULL); } -The above command blocks the client ASAP, spawining a thread that will +The above command blocks the client ASAP, spawning a thread that will wait a second and will unblock the client. Let's check the reply and timeout callbacks, which are in our case very similar, since they just reply the client with a different reply type. @@ -138,7 +138,7 @@ caller. In order to make this working, we modify the functions as follow: As you can see, now the unblocking call is passing some private data, that is the `mynumber` pointer, to the reply callback. In order to obtain this private data, the reply callback will use the following -fnuction: +function: void *RedisModule_GetBlockedClientPrivateData(RedisModuleCtx *ctx); @@ -162,7 +162,7 @@ long value must be freed. Our callback will look like the following: } NOTE: It is important to stress that the private data is best freed in the -`free_privdata` callback becaues the reply function may not be called +`free_privdata` callback because the reply function may not be called if the client disconnects or timeout. Also note that the private data is also accessible from the timeout From 2bf40c8273db3eac832045dbf40ae317e7ae7f75 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Fri, 22 Mar 2024 11:07:00 -0500 Subject: [PATCH 3/5] typo fix in BLOCK.md --- BLOCK.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BLOCK.md b/BLOCK.md index cb2831d..5948916 100644 --- a/BLOCK.md +++ b/BLOCK.md @@ -66,7 +66,7 @@ To better understand how the API works, we can imagine writing a command that blocks a client for one second, and then send as reply "Hello!". Note: arity checks and other non important things are not implemented -int his command, in order to take the example simple. +in this command, in order to take the example simple. int Example_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) From 5a6e673b1e13f1d4319017a8d4e3c8d794970b41 Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Fri, 22 Mar 2024 15:36:54 -0500 Subject: [PATCH 4/5] typo fix: must open key with `REDISMODULE_WRITE` for StringSet --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index 81a220d..de3c1f9 100644 --- a/API.md +++ b/API.md @@ -573,7 +573,7 @@ To create a new key, open it for writing and then write to it using one of the key writing functions. Example: RedisModuleKey *key; - key = RedisModule_OpenKey(ctx,argv[1],REDISMODULE_READ); + key = RedisModule_OpenKey(ctx,argv[1],REDISMODULE_WRITE); if (RedisModule_KeyType(key) == REDISMODULE_KEYTYPE_EMPTY) { RedisModule_StringSet(key,argv[2]); } From dbd4626e298355bd448bb8f04a77679e0565d37d Mon Sep 17 00:00:00 2001 From: Chenhao Ye Date: Sun, 24 Mar 2024 18:36:28 -0500 Subject: [PATCH 5/5] BLOCK.md: fix example code to make it compile --- BLOCK.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BLOCK.md b/BLOCK.md index 5948916..b32adc7 100644 --- a/BLOCK.md +++ b/BLOCK.md @@ -126,13 +126,14 @@ can be passed to the reply function so that we return it to the command caller. In order to make this working, we modify the functions as follow: void *threadmain(void *arg) { - RedisModuleBlockedClient *bc = arg; + RedisModuleBlockedClient *bc = (RedisModuleBlockedClient *)arg; sleep(1); /* Wait one second and unblock. */ long *mynumber = RedisModule_Alloc(sizeof(long)); *mynumber = rand(); RedisModule_UnblockClient(bc,mynumber); + return NULL; } As you can see, now the unblocking call is passing some private data,