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

Redis modules and blocking commands #2605

Open
v5v6 opened this issue Nov 24, 2023 · 0 comments
Open

Redis modules and blocking commands #2605

v5v6 opened this issue Nov 24, 2023 · 0 comments

Comments

@v5v6
Copy link

v5v6 commented Nov 24, 2023

In the link https://redis.io/docs/reference/modules/modules-blocking-ops/
I found the latest example code is not correct, as RedisModule_IsBlockedReplyRequest should be used the general_func other than in the Example_RedisCommand function.
BRs,

int general_func(RedisModuleCtx *ctx, RedisModuleString **argv,
int argc)
{
if (RedisModule_IsBlockedReplyRequest(ctx)) {
long *mynumber = RedisModule_GetBlockedClientPrivateData(ctx);
return RedisModule_ReplyWithLongLong(ctx,mynumber);
} else if (RedisModule_IsBlockedTimeoutRequest(ctx)) {
return RedisModule_ReplyWithNull(ctx);
}
}

int Example_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
int argc)
{

RedisModuleBlockedClient *bc =
    RedisModule_BlockClient(ctx,general_func,general_func,NULL,0);

pthread_t tid;
if (pthread_create(&tid,NULL,threadmain,bc) != 0) {
    RedisModule_AbortBlock(bc);
    RedisModule_ReplyWithError(ctx,"Sorry can't create a thread");
}

return REDISMODULE_OK;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant