java 使用reids做缓存出现redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

1、首先链接服务器 使用redis-cli

2、info

3、查看# Clients

connected_clients:23

client_longest_output_list:0

client_biggest_input_buf:0

blocked_clients:0


总结:创建连接池,一定要释放连接池。

/**

* 获取Jedis实例

    * @return

    */

  public synchronized static JedisgetJedis() {

try {

if (jedisPool !=null) {

Jedis resource =null;

              try {

resource =jedisPool.getResource();

                  return resource;

              }finally {

jedisPool.returnResource(resource);

              }

}else {

return null;

          }

}catch (Exception e) {

e.printStackTrace();

return null;

      }

}

你可能感兴趣的:(java 使用reids做缓存出现redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool)