generated from root/miduo_server
修改redis参数
parent
fca2538207
commit
623ca57143
|
@ -35,6 +35,7 @@ public class SensitiveWordApplication {
|
|||
CoreServerAutoConfiguration coreServerAutoConfiguration = configurableApplicationContext.getBean(CoreServerAutoConfiguration.class);
|
||||
CoreSettings coreSettings = coreServerAutoConfiguration.getConfig();
|
||||
String adress = coreSettings.getIp() + ":" + coreSettings.getPort();
|
||||
RedisUtil.getInstence().redisDel(RedisUtil.SENSIT_WORD_FILTER_KEY);
|
||||
RedisUtil.getInstence().redisSet(RedisUtil.SENSIT_WORD_FILTER_KEY, adress);
|
||||
new RPCServerTask(coreSettings).start();
|
||||
}
|
||||
|
|
|
@ -43,15 +43,15 @@ public class RedisUtil {
|
|||
//是否启用后进先出, 默认true
|
||||
config.setLifo(true);
|
||||
//最大空闲连接数, 默认8个
|
||||
config.setMaxIdle(100);
|
||||
config.setMaxIdle(1);
|
||||
//最大连接数, 默认8个
|
||||
config.setMaxTotal(1000);
|
||||
config.setMaxTotal(1);
|
||||
//获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1
|
||||
config.setMaxWaitMillis(-1);
|
||||
//逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
|
||||
config.setMinEvictableIdleTimeMillis(1800000);
|
||||
//最小空闲连接数, 默认0
|
||||
config.setMinIdle(100);
|
||||
config.setMinIdle(1);
|
||||
//每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
|
||||
config.setNumTestsPerEvictionRun(3);
|
||||
//对象空闲多久后逐出, 当空闲时间>该值 且 空闲连接>最大空闲数 时直接逐出,不再根据MinEvictableIdleTimeMillis判断 (默认逐出策略)
|
||||
|
@ -106,4 +106,20 @@ public class RedisUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void redisDel(String key) {
|
||||
for (int i = 0; i < MAX_TRY_TIMES; i++) {
|
||||
try {
|
||||
redisObjectTemplate.delete(key);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("redisDel->i={},key={}, emsg={}", i, key, e.getMessage(), e);
|
||||
try {
|
||||
Thread.sleep(FAILED_SLEEP);
|
||||
} catch (InterruptedException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue