How do I get pool information from org.springframe

2019-07-18 19:31发布

问题:

I'm using spring-data-redis to connect redis server. I want to get jedis' connection pool information via RedisConnectionFactory or RedisConnectionFactory. But I can't found the way to get pool object from RedisConnectionFactory.

(I guess, if there's JedisConectionFactory#getPool(), i can take the connection pool object itself)

回答1:

The pool field in JedisConnectionFactory is private and is not exposed by a getter. Your only option is to obtain the field using reflection. Besides the pool itself, you can obtain JedisPoolConfig by calling JedisConnectionFactory.getPoolConfig().

Please also note that pooling is optional (enabled by default) and can be disabled by setting JedisConnectionFactory.setUsePool(false).