首页 > 数据库 >若依微服务连接redis 一段时间报错,后来改成连接池后也是报错 Redis command timed out; nested exception is io.lettuce.core.RedisC

若依微服务连接redis 一段时间报错,后来改成连接池后也是报错 Redis command timed out; nested exception is io.lettuce.core.RedisC

时间:2023-03-21 17:22:48浏览次数:49  
标签:redis lettuce 报错 timeout timed out 连接 连接池 客户端

springBoot版本是2.x 所以呢redis客户端是lettuce,而不是jedis;

  lettuce支持异步,而且是线程安全的。

  jedis是同步的,线程不安全需要每个线程一个Jedis实例,所以一般通过连接池来使用Jedis。

我这里用的是lettuce连接池的配置还是报错了呢:

spring:
  redis:
    host: 82.156.175.242
    port: 6380
    password:
    # 连接超时时间 客户端空闲 N 秒后关闭连接(0 表示禁用)
    timeout: 10s 
    lettuce:
      pool:
        # 连接池中的最小空闲连接
        min-idle: 0
        # 连接池中的最大空闲连接
        max-idle: 8
        # 连接池的最大数据库连接数
        max-active: 8
        # #连接池最大阻塞等待时间(使用负值表示没有限制)
        max-wait: -1ms        

 new BING

spring:
  redis:
    lettuce:
      pool:
        max-active: 8 #最大活跃连接数
        max-idle: 8 #最大空闲连接数
        min-idle: 0 #最小空闲连接数
        max-wait: -1ms #最大等待时间
      shutdown-timeout: 100ms #关闭超时时间

 

 

 

参考:

Redis command timed out 两种异常情况

标签:redis,lettuce,报错,timeout,timed,out,连接,连接池,客户端
From: https://www.cnblogs.com/nextgg/p/17240715.html

相关文章