Springboot 2.4.4 + mysql
redis使用 lettuce作连接池
org.springframework.boot
spring-boot-starter-data-redis
org.apache.commons
commons-pool2
io.lettuce.core.RedisCommandTimeoutException: Command timed out
这是lettuce-core的实现里,有类似心跳机制的保持长连接方式,不过心跳机制是不停的来回发心跳包直到连接不可用再去被动重新连接,而lettuce的方案是将连接池里处于空闲(idle)状态的client每隔一段时间就主动断开,然后再重新连接。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>