Closed CurtTilmes closed 7 years ago
Hello Curt,
Thanks for your pull request. It seems redundant with 'eredis_r_reply()' function since it is already blocking.
Here is a full example of what the current api can do. It is maintaining the requests/replies iso for pipelining by managing internally the number of cmds requested/replied.
eredis_reader_t *r;
eredis_reply_t *reply; /* aka redisReply from hiredis */
/* get a reader */
r = eredis_r( e );
/* Add one request (pipelining) */
eredis_r_append_cmd( reader, "GET key1");
/* Add one request and process,
return key1 reply (the first one from queue) */
reply = eredis_r_cmd( reader, "GET key2");
if ( I_NEED_ALL_REPLIES ) {
/* current 'reply' hosts 'key1' reply */
/* Get key2 reply */
reply = eredis_r_reply( reader );
...
}
if ( I_NEED_TO_SEND_MORE ) {
/* this one fetches all possible replies left in the pipelining */
eredis_r_clear( reader );
/* reader is ready to perform a new batch of r_cmd+replies */
..
}
/* Release the reader */
eredis_r_release( r );
Regards, Guillaume
Try this:
Open two instances of redis-cli In one of them say "subscribe foo". Then, in the other one say "publish foo bar".
I want to receive the message as a reply within Eredis without first sending a corresponding request.
Oh yes, sorry i just saw the issue. I will study it and get back to you. Your pull request makes sense to me now ;-) Thanks
Please check this one, i think it fits, also with automatic reconnect. The blocking (without any timeout) is a bit sad. I will check if something is possible with at least a timeout or managing async mode.
https://github.com/EulerianTechnologies/eredis/commit/5e10c1c9c11545a566623b6be5f15b187dfa7ec0
Perfect! Much better than mine with the reconnect. Thank you. It works with my tests.
Add a function for reading a blocking reply.