Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Typos in API.md and BLOCK.md #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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]);
}
Expand Down
11 changes: 6 additions & 5 deletions BLOCK.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -126,19 +126,20 @@ 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,
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);

Expand All @@ -162,7 +163,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
Expand Down