Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add connection pools support #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

muyinliu
Copy link
Contributor

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
)

@muyinliu muyinliu mentioned this pull request Jun 16, 2014
is present)."
`(bordeaux-threads:with-lock-held (*pool-lock*) ,@body))

(defun get-from-pool (&optional group)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write (&optional (group "default"))

@vseloved
Copy link
Owner

Hi again,
Thanks for contributing this feature!

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

  • separate all the code into a separate file pool.lisp
  • write a short how-to in a spearate section in the docs (README.md), and also update the other sections where necessary
  • and the most important task, add tests to test.lisp. IMHO, connection pools are not an easy feature to maintain, as there are numerous corner cases, like handling broken connections for various reasons (incl. timeouts - an optional keep-alive feature may be added). Without tests for all or at least most of such cases from the start, I'm affraid most of the users will get poor experience from such feature

@muyinliu
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Contributor Author

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

@quasi
Copy link

quasi commented Sep 30, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants