1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| @Bean public JedisPoolConfig jedisPoolConfig(@Value("${jedis.maxTotal}") int maxActive, @Value("${jedis.maxIdle}") int maxIdle, @Value("${jedis.minIdle}") int minIdle, @Value("${jedis.maxWaitMillis}") long maxWaitMillis, @Value("${jedis.testOnBorrow}") boolean testOnBorrow) { JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); jedisPoolConfig.setMaxTotal(maxActive); jedisPoolConfig.setMaxIdle(maxIdle); jedisPoolConfig.setMinIdle(minIdle); jedisPoolConfig.setMaxWaitMillis(maxWaitMillis); jedisPoolConfig.setTestOnBorrow(testOnBorrow);
return jedisPoolConfig; }
@Bean public JedisPool jedisPool(@Value("${jedis.host}") String host, @Value("${jedis.password}") String password, @Value("${jedis.port}") int port, @Value("${jedis.timeout}") int timeout, JedisPoolConfig jedisPoolConfig) {
log.info("=====创建JedisPool连接池====="); if(StringUtils.isNotEmpty(password)) { return new JedisPool(jedisPoolConfig, host, port, timeout, password); }
return new JedisPool(jedisPoolConfig, host, port, timeout); }
|