将 StackExchange.Redis 客户端与 Redis 集群一起使用 [英] Using StackExchange.Redis client with Redis cluster

查看:177
本文介绍了将 StackExchange.Redis 客户端与 Redis 集群一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何告诉 StackExchange.Redis (v1.0.481) 它即将连接到 Redis 集群(v3.2.6,以防万一),而不仅仅是一个独立/复制的实例?例如,当我使用 redis-cli 时,我必须传递一个 -c 标志以使其能够识别集群.StackExchange.Redis 连接字符串中是否有等效标志?

How do I tell StackExchange.Redis (v1.0.481) that it's about to connect to a Redis cluster (v3.2.6, in case it matters), and not just a standalone/replicated instance? When I use the redis-cli for example, I have to pass a -c flag to make it cluster-aware. Is there an equivalent flag in the StackExchange.Redis connection string?

我搜索并发现了几个包含多个逗号分隔的 host:port 参数的连接字符串示例,但没有任何内容明确使 StackExchange.Redis 具有集群感知能力.

I've searched for and come across several examples of connection strings that include multiple comma-separated host:port parameters, but nothing that explicitly makes StackExchange.Redis cluster-aware.

谢谢.

推荐答案

如果您有一个集群,那么无论您在连接字符串上放置一个还是多个端点,您都将连接到该集群.没有连接到集群的标志.

If you have a cluster, you will connect to the cluster no matter if you put one or more endpoints on the connection string. There is no flag to connect to a cluster.

在您的连接字符串上放置多个端点有利于高可用性,因此如果其中一个节点出现故障,您将能够开始与其他节点的连接.

Putting more than one endpoint on your connection string is good for High Availability, so if one of the nodes is down, you'll be able to start the connection to other node.

内部节点列表会自动更新和扩展.您不需要将所有端点都放在连接字符串上.

The internal list of nodes is updated and expanded automatically. You don't need to put all the endpoints on the connection string.

查看此问题了解更多详情.

这篇关于将 StackExchange.Redis 客户端与 Redis 集群一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆