首页 > 解决方案 > 从 Spring Boot 缓存抽象连接到 Redis 集群

问题描述

我正在使用具有缓存抽象支持的 Spring Boot 连接到 redis-server 以存储/获取数据以进行缓存。

我使用以下属性连接到 redis-server。

spring.redis.host=localhost
spring.redis.port=6379
spring.redis.password=mypassword
spring.cache.type=redis

我能够成功连接到 redis 服务器并存储/获取数据。

为了高可用,决定使用 3 个节点,1 个主节点和 2 个从节点作为 redis 服务器。

在这种情况下,我不确定如何提供配置以从我的 Spring Boot 应用程序连接到 Redis 集群。

spring boot 是否有任何属性支持连接到redis集群。

我正在使用对 Spring 缓存抽象的开箱即用支持以及对注解@cacheable 的支持。

我在 pom.xml spring-boot-starter-cachespring-boot-starter-data-redis中添加了以下 2 个依赖项 ,并且还使用了spring boot 1.5.13。

在spring boot中使用spring缓存抽象时是否支持连接redis集群。

标签: spring-bootcachingredis

解决方案


推荐阅读