0
0

Jedis连接池

2024-07-17
文章摘要
|
/**
 * @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();
    }
}

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或者给予支持!