add redis database config

pull/1/head
wangdongxun 2016-09-22 14:33:37 +08:00
parent ee04495e20
commit 3740cf404c
1 changed files with 4 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public class RedisManager
poolConfig.setNumTestsPerEvictionRun(testNumPerEviction);
long timeBetweenEviction = Long.parseLong(properties.getProperty(RedisConstants.TIME_BETWEENEVICTION, RedisConstants.DEFAULT_TIME_BETWEENEVICTION_VALUE));
poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEviction);
int database = Integer.parseInt(properties.getProperty(RedisConstants.DATABASE, "0"));
String hosts = properties.getProperty(RedisConstants.HOSTS, Protocol.DEFAULT_HOST.concat(":").concat(String.valueOf(Protocol.DEFAULT_PORT)));
String host = null;
int port = 0;
@ -74,8 +75,10 @@ public class RedisManager
if (password == null || password == "" || password.isEmpty()) {
pool = new JedisPool(poolConfig, host, port);
} else {
pool = new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, password);
// pool = new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, password);
pool =new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, password,database);
}
}
public Jedis getJedis() {