首页 > 解决方案 > 使用 spring-boot-starter-data-redis-reactive 启用 Master/Replica 操作

问题描述

我正在使用 spring-boot-starter-data-redis-reactive 和 @SpringBootApplication 注解来自动配置 redis 连接。我已经建立了一个有 1 个主设备和 2 个从设备的 redis 集群。我在 application.properties 文件中有以下配置

spring.redis.cluster.nodes=master-node:6379,slave1-node:6379,slave2-node:6379

我想对其进行配置,以便所有写入都转到主机,所有读取都转到从机(首选从机)。

我发现它在引擎盖下使用了生菜驱动程序。为了实现这一点,我需要添加.readFrom(SLAVE_PREFERRED)LettuceClientConfiguration. 看了org\springframework\boot\autoconfigure\data\redis\LettuceConnectionConfiguration.class看,我没有看到添加此配置的方法。知道如何实现这一目标吗?

标签: spring-bootspring-data-redisredis-clusterspring-boot-starter

解决方案


推荐阅读