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

Does hiredis cluster support reconnect after disconnect #98

Closed
qianqians opened this issue Jun 14, 2022 · 1 comment
Closed

Does hiredis cluster support reconnect after disconnect #98

qianqians opened this issue Jun 14, 2022 · 1 comment

Comments

@qianqians
Copy link

qianqians commented Jun 14, 2022

i use hiredis cluster like this

ctx = redisClusterContextInit();
redisClusterSetOptionAddNodes(ctx, redis_url.c_str());
if (!password.empty()) {
redisClusterSetOptionPassword(ctx, password.c_str());
}
redisClusterSetOptionRouteUseSlots(ctx);
redisClusterConnect2(ctx);`

my question is redisClusterAsyncContext have redisClusterAsyncSetDisconnectCallback process dissconnect event, but redisClusterContext not have correspond method, does it means when i use redisClusterContext, it automatic processing dissconnect?

@bjosv
Copy link
Collaborator

bjosv commented Jun 15, 2022

When a command is sent hiredis-cluster will first check if there is a working connection to the redis node that handles the specific key. If a previous query failed due to communication issues a reconnection attempt is performed automatically.

For the async API the callback is only used to notify the user about a disconnect, so there is no need to call a connect method here either.

Another note about your example is to make sure that redisClusterConnect2(ctx); results in REDIS_OK.

@bjosv bjosv closed this as completed Feb 16, 2023
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

2 participants