parent
897b15ac10
commit
6239e6f12b
|
@ -1,6 +1,14 @@
|
|||
# redis hosts ex: 127.0.0.1:6379, 127.0.0.2:6379, 127.0.0.2:6380, ....
|
||||
redis.hosts=127.0.0.1:6379
|
||||
|
||||
# Redis Password
|
||||
redis.password=
|
||||
|
||||
# set true to enable redis cluster mode
|
||||
redis.cluster.enabled=false
|
||||
redis.cluster.enabled=false
|
||||
|
||||
# Redis database (default 0)
|
||||
#redis.database=0
|
||||
|
||||
# Redis connection timeout (default 2000)
|
||||
#redis.timeout=2000
|
|
@ -59,7 +59,8 @@ public class RedisClusterManager
|
|||
poolConfig.setNumTestsPerEvictionRun(testNumPerEviction);
|
||||
long timeBetweenEviction = Long.parseLong(properties.getProperty(RedisConstants.TIME_BETWEENEVICTION, RedisConstants.DEFAULT_TIME_BETWEENEVICTION_VALUE));
|
||||
poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEviction);
|
||||
jedisCluster = new JedisCluster(getJedisClusterNodesSet(properties.getProperty(RedisConstants.HOSTS, Protocol.DEFAULT_HOST.concat(":").concat(String.valueOf(Protocol.DEFAULT_PORT)))), poolConfig);
|
||||
int timeout = Integer.parseInt(properties.getProperty(RedisConstants.TIMEOUT, String.valueOf(Protocol.DEFAULT_TIMEOUT)));
|
||||
jedisCluster = new JedisCluster(getJedisClusterNodesSet(properties.getProperty(RedisConstants.HOSTS, Protocol.DEFAULT_HOST.concat(":").concat(String.valueOf(Protocol.DEFAULT_PORT)))), (timeout < Protocol.DEFAULT_TIMEOUT ? Protocol.DEFAULT_TIMEOUT : timeout), poolConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,11 +71,9 @@ public class RedisManager
|
|||
}
|
||||
}
|
||||
String password = properties.getProperty(RedisConstants.PASSWORD);
|
||||
if (password == null || password == "" || password.isEmpty()) {
|
||||
pool = new JedisPool(poolConfig, host, port);
|
||||
} else {
|
||||
pool = new JedisPool(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, password);
|
||||
}
|
||||
int database = Integer.parseInt(properties.getProperty(RedisConstants.DATABASE, String.valueOf(Protocol.DEFAULT_DATABASE)));
|
||||
int timeout = Integer.parseInt(properties.getProperty(RedisConstants.TIMEOUT, String.valueOf(Protocol.DEFAULT_TIMEOUT)));
|
||||
pool = new JedisPool(poolConfig, host, port, (timeout < Protocol.DEFAULT_TIMEOUT ? Protocol.DEFAULT_TIMEOUT : timeout), ((password == null || password == "" || password.isEmpty()) ? null : password), database);
|
||||
}
|
||||
|
||||
public Jedis getJedis() {
|
||||
|
|
|
@ -24,7 +24,9 @@ public class RedisConstants
|
|||
public static final String HOSTS = "redis.hosts";
|
||||
public static final String PASSWORD = "redis.password";
|
||||
public static final String IS_CLUSTER_ENABLED = "redis.cluster.enabled";
|
||||
|
||||
public static final String DATABASE = "redis.database";
|
||||
public static final String TIMEOUT = "redis.timeout";
|
||||
|
||||
// Redis property default values
|
||||
public static final String DEFAULT_MAX_ACTIVE_VALUE = "10";
|
||||
public static final String DEFAULT_TEST_ONBORROW_VALUE = "true";
|
||||
|
|
|
@ -229,7 +229,7 @@ public class RequestSessionManager extends ManagerBase implements Lifecycle
|
|||
|
||||
@Override
|
||||
public void remove(Session session, boolean update) {
|
||||
requestSessionCacheUtils.deleteKey(session.getId());
|
||||
requestSessionCacheUtils.expire(session.getId(), 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -296,8 +296,11 @@ public class RequestSessionManager extends ManagerBase implements Lifecycle
|
|||
currentSessionSerializationMetadata.set(updatedSerializationMetadata);
|
||||
currentSessionIsPersisted.set(true);
|
||||
}
|
||||
log.trace("Setting expire timeout on session [" + customSession.getId() + "] to " + (getContext().getSessionTimeout() * 60));
|
||||
requestSessionCacheUtils.expire(customSession.getId(), (getContext().getSessionTimeout() * 60));
|
||||
|
||||
int timeout = getContext().getSessionTimeout() * 60;
|
||||
timeout = timeout < 1800 ? 1800 : timeout;
|
||||
log.trace("Setting expire timeout on session [" + customSession.getId() + "] to " + timeout);
|
||||
requestSessionCacheUtils.expire(customSession.getId(), timeout);
|
||||
} catch (IOException e) {
|
||||
log.error("Error occured while storing the session object into redis", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue