How to reuse redis(JRedis) pool connection in Java
<p>I am using Redis(3.2.100) for Windows to cache my database data in Java.This is my redis init code:</p>

<pre><code>private static Dictionary&lt;Integer, JedisPool&gt; pools = new Hashtable();

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(2);
        config.setMaxTotal(10);
        config.setTestOnBorrow(true);
        config.setMaxWaitMillis(2000);
        for (int i = 0; i &lt; 16; i++) {
            JedisPool item  = new JedisPool(config, "127.0.0.1", 6379,10*1000);
            pools.put(i, item);
        }
    }
</code></pre>

<p>This is the cache code:</p>

<pre><code>public static String get(String key, Integer db) {
        JedisPool poolItem = pools.get(db);
        Jedis jredis = poolItem.getResource();
        String result = jredis.get(key);
        return result;
    }
</code></pre>

<p>The problem is when the program run for a while,the getResource method throws:</p>

<pre><code>redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
</code></pre>

<p>So how to reuse the connection or close the connection.I am using this command to find out that the client has reached the max value.</p>

<pre><code>D:\Program Files\Redis&gt;redis-cli.exe info clients
# Clients
connected_clients:11
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
</code></pre>

<p>How to fix it?</p>