使用spring-boot-starter-data-redis-active启用主/复制操作

时间:2019-07-15 20:34:04

标签: spring-boot spring-data-redis redis-cluster spring-boot-starter

我正在使用spring-boot-starter-data-redis-reactive和@SpringBootApplication批注自动配置Redis连接。我设置了一个Redis集群,其中包含1个主节点和2个从节点。我在application.properties文件中有以下配置

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

我想对其进行配置,以使所有写入均归主,所有读取均归从属(首选从属)。

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

0 个答案:

没有答案