How Jedis Pool works?

前端 未结 1 763
面向向阳花
面向向阳花 2020-12-24 05:59

I\'m using Jedis pool to manage connections to Redis server. An example code of mine as follows:

public Set

        
相关标签:
1条回答
  • 2020-12-24 06:26

    You haven't configured the maxTotal size of the pool, and the default value is only 8. You could change the JedisFactory constructor to:

    
        public JedisFactory() {
            JedisPoolConfig poolConfig = new JedisPoolConfig();
            poolConfig.setMaxTotal(128);
            jedisPool = new JedisPool(poolConfig, RedisDBConfig.HOST, RedisDBConfig.PORT, RedisDBConfig.TIMEOUT, RedisDBConfig.PASSWORD);
        }
    

    Beware also of the default value of the WhenExhaustedAction (WHEN_EXHAUSTED_BLOCK), as it may not be your desired behavior.

    Jedis uses Apache Commons Pool, and you can read about it's parameters here: GenericObjectPool

    0 讨论(0)
提交回复
热议问题