Changed pool implementation to allow limiting the amount of connections #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
StackObjectPool
allows for unlimited amount of connections in the pool. We experienced with that connection timeouts (most probably because the amount of sockets in the system became huge). Limiting the amount of RedisClients using theGenericObjectPool
does fix that.Also, usage of cloud Redis solutions sometimes have connection limitations, so in that case it is useful to be able to restrict the max amount of connections being allowed. It's anyway good to restrict resource usage as things are finite anyhow (and it's better to be in control of the limit then to let the system limit the resources as the latter might give unexpected exceptions).
The default limit is -1 (unlimited) for backwards compatibility reasons. If you feel that some limit is better, feel free to change.
I've enabled testing on Return (calls validateObject() on the factory), but disabled testing on borrow (as the write method in IO also takes care of that).