【发布时间】:2016-09-20 03:42:53
【问题描述】:
这是使用 stackexchange.redis v1.1.603、.net 4.6、控制台应用程序。 这是我的代码:
using System;
using System.Collections.Generic;
using StackExchange.Redis;
namespace RedisClusterTesting
{
class Program
{
static void Main(string[] args)
{
string ip = "192.168.1.20:30001,192.168.1.20:30002,192.168.1.20:30003,resolvedns=1";
var conf = ConfigurationOptions.Parse(ip);
conf.CommandMap = CommandMap.Create(new HashSet<string> {
"INFO", "CONFIG", "CLUSTER","PING", "ECHO", "CLIENT"
}, false);
using (ConnectionMultiplexer conn = ConnectionMultiplexer.Connect(conf))
{
var db = conn.GetDatabase();
Do(db);
}
Console.ReadKey();
}
private static void Do(IDatabase db)
{
/*here throws MOVED Exception:MOVED 12182 192.168.1.20:30003*/
db.StringSet("foo", "changed");
Console.WriteLine("foo now:" + db.StringGet("foo").ToString());
}
}
}
始终显示消息“已移动:12586[192.168.1.20:30003]”。
我搜索了所有的官方文档和互联网,找不到正确的答案。我用redis-cli就可以了。
如何解决这个问题?我是否需要在我的代码中处理异常?如果,如何解决?
【问题讨论】:
-
我已经修好了。在我解决了另一个问题后它就可以工作了。
-
你能告诉我们什么问题吗?我有同样的问题
标签: c# redis stackexchange.redis redis-cluster