Redis client : create new connections when pool size gets exhausted

1.8k Views Asked by At

We are using redis for caching purpose in our application.

Our goal is to create new Redis connections as the pool size exhaust or crosses a certain threshold so that we can keep the number of idle connections minimal . This way a redis-server resource is allocated to a application-server which really needs it.

In our java application we are using spring's JedisConnectionFactory of spring-data-redis 1.4.2 which internally uses Jedis 2.6.2 and commons-pool 2.0 .

The latest versions of GenericObjectPool does not have option of growing pool size dynamically. (Earlier versions of commons-pool had whenExhaustAction option)

I also could not find a way to pass a custom object pool in Jedis.

Please suggest how can we achieve this. Does any other Redis-Client has a support for this?

1

There are 1 best solutions below

0
On

If you set the maxTotal property to a negative value, there will be no limit to the number of instances in the pool. You can combine this with a maxIdle setting to ensure that there are no more than maxIdle idle connections at any given time.