StackExchange.Redis连接redis集群
报错:其他信息: Endpoint 127.0.0.1:7002 serving hashslot 15224 is not reachable at this point of time. Please check connectTimeout value. If it is low, try increasing it to give the ConnectionMultiplexer a chance to recover from the network di
sconnect.
代码:
public static ConnectionMultiplexer Instance
{
get
{
if (_instance == null)
{
lock (Locker)
{
if (_instance == null || !_instance.IsConnected)
{
_instance = GetManager();
}
}
}
return _instance;
}
}
public static ConnectionMultiplexer GetConnectionMultiplexer(string connectionString)
{
if (!ConnectionCache.ContainsKey(connectionString))
{
ConnectionCache[connectionString] = GetManager(connectionString);
}
return ConnectionCache[connectionString];
}
public bool StringSet(string key, string value, TimeSpan? expiry = default(TimeSpan?))
{
key = AddSysCustomKey(key);
var profiler = new RedisProfiler();
_conn.RegisterProfiler(profiler);
_conn.BeginProfiling(profiler.MyContext);
var db = _conn.GetDatabase();
db.StringSet(key, value, expiry);
db.StringSet("hello", "world");
var msgs = _conn.FinishProfiling(profiler.MyContext);
return true;
}