Skip to content

Jedis连接池

java
/**
 * @author xclhove
 */
public class JedisConnectionFactory {
    private static final JedisPool JEDIS_POOL;
  
    static {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        // 最大连接数
        jedisPoolConfig.setMaxTotal(10);
        // 最大空闲连接数
        jedisPoolConfig.setMaxIdle(10);
        // 最小空闲连接数
        jedisPoolConfig.setMinIdle(0);
        jedisPoolConfig.setMaxWait(Duration.ofSeconds(3));
        JEDIS_POOL = new JedisPool(jedisPoolConfig, "127.0.0.1", 6379, 3000);
    }
  
    public static Jedis getJedis() {
        return JEDIS_POOL.getResource();
    }
}

最近更新:7/17/2024, 2:58:21 PM

原文链接:Jedis连接池

|下一篇:植物大战僵尸杂交版v2.1无法开启3D加速解决办法