vseloved / cl-redis

Redis client for Common Lisp
Other
188 stars 38 forks source link

Add connection pools support #20

Open muyinliu opened 10 years ago

muyinliu commented 10 years ago

Add connection pools support.

Usage:

;; initial connection pool
(redis:init-connection-pool :port 6347 :count 15)

;; use connection pool
(redis:with-connection-in-pool
    ;; your code
)
vseloved commented 10 years ago

Hi again, Thanks for contributing this feature!

But before it can be merged into master we need to do the following:

muyinliu commented 10 years ago

You are right! A lot of work to do. I will do the first two jobs you mention. But I don't know how to write the test case for this... I need your help.

muyinliu commented 10 years ago

I will spend some time to take a look at Jedis(an Java implement of redis-cli). As I know, Jedis has perfect feature about connection pools.

vseloved commented 10 years ago

You can take a look at the tests already present. First, I'd start with simple tests, like: take a connection from the pool, ensure that the number of connections decreased, ensure that you can ping the server, return the connection, ensure that it increased. Then I'd try to play with closing the connection from the code or by shutting down the server and seeing its effects, adding appropriate error-handling code, and finally adding tests to ensure that the code works.

vseloved commented 10 years ago

Well, actually, my experience with Jedis is one of the reasons I think working supporting connection pools is hard :) (It was, actually, quite painful experience, when connections became unusable completely unpredictably and it was very hard to tackle that)

muyinliu commented 10 years ago

Thanks for your patience! I will try my best to complete this feature! Writing the test case will be a experience for myself.

quasi commented 1 year ago

You could check out https://github.com/quasi/pooler for pooling functionality