0

I am trying to write connection pool using hiredis. Problem I am facing is , if user fires a command and didn't read the response from the connection, I should be clearing the response from that connection before putting to connection pool.

Is there any way to check:

  1. Is there more data to read? So I can do redisGetReply , till all data get cleared.
  2. Or is there a way to clear all pending read on connection object ?
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186

1 Answers1

0

Question is not clear, as it fails to state whether you are using sync or async operations.

  • You mention redisGetReply, I would assume use of sync operations. Sync calls would be blocking calls. Response to commands would be available in the same call. A scenario where you might want to check if all data is read is when context is shared between threads and you check for data before returning connection to pool.

    Yes redisGetReply can be used to check if there is more data to read.

    For async calls use redisAsyncHandleRead to check if there is data to be read.

Internally both redisGetReply and redisAsyncHandleRead make call to redisBufferRead.

  • For sync calls use redisFree to clear context. For Aysnc calls use redisAsyncFree to clear context.
Nik
  • 1,294
  • 10
  • 16