spring-boot - 使用 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
看,我没有看到添加此配置的方法。知道如何实现这一目标吗?
解决方案
推荐阅读
- python-3.x - Gurobi 使用 addVar 中的 obj 参数
- google-pay - 如何测试草稿中的 Google Pay 课程?
- php - 使用 REST API php 在 KOHA 中传递令牌
- r - 在 R 中将 2 个图合并为 1 个图
- asp.net - ASP.NET:面板未使用 visible=true 呈现
- sql - 在选择中选择?
- javascript - 问题重新索引嵌套对象数组中的项目
- perl - Mojo::UserAgent - 在解码前检查 Content-Encoding 标头
- angular - Spring Boot + Angular 应用程序作为 WAR 部署到 Heroku,抛出 404,除非我在 URL 中包含“index.html”
- vue.js - 向列表添加多个排序/过滤选项 - 最佳方法?