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 SSUBSCRIBE? #166

Open
arwace opened this issue Jun 15, 2023 · 2 comments
Open

Does hiredis-cluster support SSUBSCRIBE? #166

arwace opened this issue Jun 15, 2023 · 2 comments

Comments

@arwace
Copy link

arwace commented Jun 15, 2023

Neither synchronous nor asynchronous mode can handle SSUBSCRIBE.

Is there an example that handles SSUBSCRIBE?

@zuiderkwast
Copy link
Collaborator

Hi @arwace!

No, unfortunately hiredis-cluster does not support any kind of subscribe (SUBSCRIBE, PSUBSCRIBE, SSUBSCRIBE). See #27.

Regarding SSUBSCRIBE, not even the underlying hiredis supports it. See redis/hiredis#1066.

redis-cli (which comes with redis) can support ssubscribe and it uses hiredis, but it does it's own handling. (It calls redisGetReply() repeatedly and checks if each reply looks like a pushed pubsub message.)

@zuiderkwast
Copy link
Collaborator

If you have a blocking thread to consume messages, one possible workaround is to use hiredis directly. You can get the hiredis context from hiredis-cluster like this:

redisClusterNode *node = redisClusterGetNodeByKey(cc, "channel");
redisContext *c = ctx_get_by_node(cc, node);

Then use hiredis functions with context c, for example to get all pubsub messages in a loop.

redisReply *reply = redisCommand(c, "SSUBSCRIBE channel");
freeReplyObject(reply);
while (redisGetReply(c, (void *)&reply) == REDIS_OK) {
    // consume message
    freeReplyObject(reply);
}

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