这里会记录redis的一些常用命令与理论
redis常用命令
容器内安装redis
apk add redis
ps -ef|grep redis
which redis-cli
redis-cli -h 192.168.201.208
auth redis_pwd
查询配置
config get tcp-keepalive
查询redis客户端总数,我见过1000多的,也有几十个的
info clients
查询redis客户端列表信息
client list
查询redis最大客户端连接数,默认是10000
config get maxclients
查询大key
redis-cli -h www.baidu.com -a password --bigkeys
redis知识理论
redis默认的tcp-keepalive是300秒,可以通过添加依赖,自定义tcp_user_timeout
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-x86_64</classifier>
</dependency>
代码实现
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();
}