EulerianTechnologies / eredis

Fast and light Redis C client library built over Hiredis, thread-safe, write replication, auto-reconnect, sync pool, async libev.
BSD 3-Clause "New" or "Revised" License
81 stars 38 forks source link

Example #4

Closed limbo127 closed 8 years ago

limbo127 commented 8 years ago

Can you put some examples ? Is eredis_reply_free must be use with simple eredis_r_cmd ? How count reader ( thread ?) that opens in pool connection ?

Regards, Nicolas Prochazka

guillaumef commented 8 years ago

Hi, You have some examples in test__.c files. eredis_reply_free must be use on any eredis_replyt detached via eredis_r_reply_detach(). If not, the engine manage the eredis_reply_t* structure itself to avoid reallocation on next reader request. eredis.h includes the short documentation.

To ease on the api, eredis manages itself the readers queue with an upper limit. You can set the maximum number of readers in the pool via eredis_r_max(). The default limit is low (10) since the goal is to minimize the number of readers to avoid too many open sockets. This way, in a pthread context, the right process should be to get a reader, make a request and release it since eredis is managing the max number of readers in an LRU fashion to minimize the number of reconnections due to possible timeouts. If the max number of readers is reached (meaning they are all in use), eredis_r() will block until a reader is available.

Regards, guillaume