Spring Boot 2 默认的 Redis 缓存客户端

huangapple go评论124阅读模式
英文:

Spring boot 2 Redis cache default client

问题

我正在使用Spring Boot 2和以下依赖项来使用Redis缓存:

implementation 'org.springframework.boot:spring-boot-starter-data-redis'

正如我之前所了解的,Lettuce是Redis的默认客户端。但是,当我开始使用属性(即使是默认属性)进行配置时,出现了错误。

spring:
 redis:
  lettuce:
    pool:
      max-active: 8
      max-idle: 8
      max-wait: -1
      min-idle: 0

为了恢复服务,我可以添加common-pool2:

implementation group: 'org.apache.commons', name: 'commons-pool2', version: '2.8.1'

看起来,只有在设置属性后,Spring Boot才开始使用这个连接池。

因此,问题是Spring Boot默认使用的确切Redis客户端是什么,以及默认设置了哪些属性?

英文:

I am using Spring Boot 2 and this dependency to use redis cache:

implementation 'org.springframework.boot:spring-boot-starter-data-redis'

As I read before Letucce is a default client for Redis. But, when I started to configure it with properties (even default) it become failed.

spring:
 redis:
  lettuce:
    pool:
      max-active: 8
      max-idle: 8
      max-wait: -1
      min-idle: 0

To recover service I can add common-pool2:

implementation group: 'org.apache.commons', name: 'commons-pool2', version: '2.8.1'

It looks like spring boot starts to use this pool only after setting properties.

So, the question is what exact redis client is used by Spring Boot by default and what properties are set by default?

答案1

得分: 0

经过一些研究,我必须说默认行为不是异步的。这就是为什么根本没有使用池。添加Lettuce客户端使我们使用外部池。

英文:

After some research, I have to say that default behavior is not async. That is why there are no pools used at all. Adding the Lettuce client leads us to use an external pool.

huangapple
  • 本文由 发表于 2020年8月24日 16:56:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/63557753.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定