springboot2.0整合redis集群,其实好简单

发布时间 2023-08-17 16:12:09作者: 咔咔皮卡丘

配置

#redis配置
redis:
   cluster:
     nodes:
      - 127.0.0.1:9000
      - 127.0.0.1:9001
      - 127.0.0.1:9002
      - 127.0.0.1:9003
      - 127.0.0.1:9004
      - 127.0.0.1:9005
   timeout: 6000ms
   password:
   lettuce:
     pool:
       max-active: 8
       max-wait: -1ms
       max-idle: 8
       min-idle: 0
   database: 0

 

依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- 集群需要 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-pool2</artifactId>
</dependency>