1

I have few questions as below regarding Hiredis for C:

I read somewhere that hiredis does not do connection pooling. Is there any library available for hiredis which does connection pooling or may be an alternative to hiredis which has connection pooling.

For other question I'll give the background below:

In the code I plan to use the same context through out until the application stops, don't know is this the correct way and what are the complications of doing this. Please correct me if I am doing anything wrong. The way I want to do is, the app forks few child once started. I will create the context in the child initialization and use it for all the requests the process serves. Also, I can check the reply of redisCommand and try to reconnect as:

reply = redisCommand(c,"set %s %s","key","value");
    if(reply == NULL)
    {
        printf("Connection error.\n");
        c = redisConnect(hostname,port);
        // checks

    }

**Q:**How can I check if context is still valid, means the connection is not lost? I see REDIS_CONNECTED in hiredis.h but not sure this is what can tell this. I printed this variable after creating context which printed 2 and then I stopped the DB but still it printed 2 and program segfaulted. Does hiredis handles reconnection.

EDIT: I am no expert in C, I would appreciate if I can get some useful links from where I can learn how to create and use connection pools in C.

Thanks

user3275095
  • 1,605
  • 4
  • 24
  • 36

0 Answers0