gpt4 book ai didi

redis - 是否可以传递给 lettuce redis library MasterSlave connection only slaves uris?

转载 作者:可可西里 更新时间:2023-11-01 11:23:26 34 4
gpt4 key购买 nike

我的目标是只添加从属 URI,因为在我的情况下主站不可用。但是生菜库返回

io.lettuce.core.RedisException: Master 当前未知:[RedisMasterSlaveNode [redisURI=RedisURI [host='127.0.0.1', port=6382], role=SLAVE], RedisMasterSlaveNode [redisURI=RedisURI [ host='127.0.0.1', port=6381], role=SLAVE]]

所以问题是:是否有可能以某种方式避免此异常?也许配置。提前谢谢你

更新:忘了说在从池中借用对象后,我在运行命令之前设置了 connection.readFrom(ReadFrom.SLAVE)

GenericObjectPoolConfig config = fromRedisConfig(properties);
List<RedisURI> nodes = new ArrayList<>(properties.getUrl().length);
for (String url : properties.getUrl()) {
nodes.add(RedisURI.create(url));
}
return ConnectionPoolSupport.createGenericObjectPool(
() -> MasterSlave.connect(redisClient, new ByteArrayCodec(), nodes), config);

最佳答案

问题是我试图设置数据,这只能通过主节点实现。所以MasterSlave是没有问题的。获取数据完美运行

关于redis - 是否可以传递给 lettuce redis library MasterSlave connection only slaves uris?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56648945/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com