这里会记录redis的一些常用命令与理论
redis常用命令
ps -ef|grep redis
which redis-cli
redis-cli -h 192.168.201.208
auth redis_pwd
查询配置
config get tcp-keepalive
redis知识理论
redis默认的tcp-keepalive是300秒,可以通过添加依赖,自定义tcp_user_timeout
io.netty
netty-transport-native-epoll
linux-aarch_64
io.netty
netty-transport-native-epoll
linux-x86_64
代码实现
protected ClientResources createClientResource() {
return ClientResources.builder()
.nettyCustomizer(new NettyCustomizer() {
@Override
public void afterBootstrapInitialized(Bootstrap bootstrap) {
if (EpollProvider.isAvailable()) {
// TCP_USER_TIMEOUT >= TCP_KEEPIDLE + TCP_KEEPINTVL * TCP_KEEPCNT
// https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/
bootstrap.option(EpollChannelOption.TCP_USER_TIMEOUT, 7000);
}
}
}).build();
}