您好,欢迎来到纷纭教育。
搜索
您的当前位置:首页jedispool工具类

jedispool工具类

来源:纷纭教育

public class RedisUtil {

    private static final JedisPool pool;

    static { //静态代码块
        JedisPoolConfig conf = new JedisPoolConfig();
        //最大空闲连接
        conf.setMaxIdle(10);
        //最大总连接数
        conf.setMaxTotal(100);
        //
        conf.setMinIdle(2);
        conf.setTestOnCreate(true);
        conf.setTestOnBorrow(true);
        conf.setTestOnReturn(true);
        conf.setMaxWaitMillis(10000);
        pool = new JedisPool(conf, "hadoop162", 6379);
    }
    public static Jedis getJedis() {
        Jedis jedis = pool.getResource();
        jedis.select(4);
        return jedis;
    }
    public static void close (Jedis jedis){
        if (jedis!= null){
            jedis.close();
        }
    }
}

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- fenyunshixun.cn 版权所有 湘ICP备2023022495号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务