public class Test { private static Pool<Jedis> pool; static{ JedisPoolConfig config = new JedisPoolConfig(); //最大连接数 config.setMaxTotal(800); //最大空闲连接数 config.setMaxIdle(10); //连接耗尽时是否阻塞, false报异常,ture阻塞直到超时 config.setBlockWhenExhausted(false); //在获取连接的时候检查有效性 config.setTestOnBorrow(true); pool = new JedisPool(config, "10.110.20.152", 6379); } public static Jedis getConnection() { Jedis jedis = pool.getResource(); return jedis; } public static void main(String[] args) { Jedis jedis = getConnection(); Map<String, String> value = jedis.hgetAll("apis"); System.out.println(value); jedis.close(); } }
Jedis连接池 Jedis Pool
猜你喜欢
转载自huangqiqing123.iteye.com/blog/2390404
今日推荐
周排行