支持redis密码

This commit is contained in:
showsoso 2017-06-22 11:39:04 +08:00 committed by GitHub
parent d27bc15a08
commit a05f33d7ea

View File

@ -37,13 +37,23 @@ public class RedisCacheStorager<T extends Cacheable> implements
}
public RedisCacheStorager(String host, int port, int timeout) {
JedisPoolConfig jedisPoolConfig = defaultConfig();
this.jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout);
}
public RedisCacheStorager(String host, int port, int timeout, String password) {
JedisPoolConfig jedisPoolConfig = defaultConfig();
this.jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);
}
private JedisPoolConfig defaultConfig(){
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(MAX_TOTAL);
jedisPoolConfig.setMaxIdle(MAX_IDLE);
jedisPoolConfig.setMaxWaitMillis(MAX_WAIT_MILLIS);
jedisPoolConfig.setTestOnBorrow(TEST_ON_BORROW);
jedisPoolConfig.setTestOnReturn(TEST_ON_RETURN);
this.jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout);
return jedisPoolConfig;
}
public RedisCacheStorager(JedisPoolConfig jedisPoolConfig) {
@ -128,4 +138,4 @@ public class RedisCacheStorager<T extends Cacheable> implements
}
}
}
}
}