spring boot cache 結合 redis 快取機制設定
使用spring boot版本:2.1.6
- pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency>
- application.yml
增加快取管理設定
reference:
Redis Sentinel Support https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:sentinel
spring: cache: type: REDIS redis: jedis: pool: max-idle: 8 min-idle: 0 max-active: 8 max-wait: -1 sentinel: master: mymaster nodes: 127.0.0.1:26379