最近在使用redis出现以下的异常:
1.redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection timed out
2.redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:22)
3.redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket is not connected
4.redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket closed
总结:
a.程序中一定存在没有关闭的redis连接;
b.jedis驱动包版本过低,本项目报错之前使用jedis-2.1.0.jar,现在项目使用jedis-2.7.3.jar,两个版本在使用JedisPoolConfig 设置最大连接数的方法和等待时间方法不一样;
c.jedis工具类:http://blog.csdn.net/lu_wei_wei/article/details/50906251