You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级StackExchange.Redis至2.6.48后EndPoints初始化错误求助

关于StackExchange.Redis 2.6.48中EndPoints的问题解答

1. EndPoints是否被移除?

是的,StackExchange.Redis从2.6.x版本开始,移除了ConfigurationOptions类中可直接通过对象初始化器设置的EndPoints属性,这就是你收到错误提示的原因。

2. 替代项是什么?

现在需要通过ConfigurationOptions的EndPoints集合方法来添加端点,常用的操作方式有:

  • 使用Add(string hostAndPort):直接传入主机名+端口的字符串,比如"localhost:6379"
  • 使用Add(string host, int port):分开传入主机名和端口
  • 使用Add(EndPoint endPoint):传入已构建的EndPoint对象

示例代码:

var config = new ConfigurationOptions();
config.EndPoints.Add("localhost:6379");
// 或者分开传入主机和端口
config.EndPoints.Add("localhost", 6379);

3. 其他连接Redis端点的方式

除了通过ConfigurationOptions添加端点,还有两种常用方式:

  • 直接使用连接字符串:把端点信息写在连接字符串里,单个端点格式为host:port,多个端点用逗号分隔,示例:
    var conn = ConnectionMultiplexer.Connect("localhost:6379,redis-server:6380");
    
  • 解析连接字符串后修改配置:先使用ConfigurationOptions.Parse解析基础连接字符串,再补充其他配置或端点,示例:
    var config = ConfigurationOptions.Parse("localhost:6379");
    config.EndPoints.Add("redis-server:6380");
    var conn = ConnectionMultiplexer.Connect(config);
    

内容的提问来源于stack exchange,提问作者Saurabh_Sitank

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 18:48:24