[英]StackExchange.Redis Lazy connection configuration
I'am trying to implement Redis cache service by StackExchange.Redis library. 我正在尝试通过StackExchange.Redis库实现Redis缓存服务。
My Redis client: 我的Redis客户:
public class RedisClient
{
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
return ConnectionMultiplexer.Connect(string.Format("{0},{1}",
ConfigurationManager.AppSettings.GetStringOrDefault("redis_masters", "someIP1:6379"),
ConfigurationManager.AppSettings.GetStringOrDefault("redis_slaves", "someIP2:6379")));
});
public static ConnectionMultiplexer GetConnection
{
get
{
return lazyConnection.Value;
}
}
}
And i try to get connection in this way: 我尝试以这种方式获得连接:
using (var redis = RedisClient.GetConnection)
{
...
}
I get exception: "It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. UnableToResolvePhysicalConnection on PING" 我收到异常消息: “无法连接到Redis服务器;要创建断开的多路复用器,请禁用AbortOnConnectFail。在PING上禁用UnableToResolvePhysicalConnection”
I also tried to add some configuration to connection like this: 我还尝试为连接添加一些配置,如下所示:
ConnectionMultiplexer.Connect(string.Format("{0},{1},Ssl=false"
And i get another exception: "ValueFactory attempted to access the Value property of this instance." 我得到另一个例外: “ ValueFactory试图访问此实例的Value属性。”
My connection to Redis worked fine with enother library : "StackExchange.Redis"
I just try to migrate is to "ServiceStack.Redis"
What i missing? 我与Redis的连接在其他库中运行良好: "StackExchange.Redis"
StackExchange.Redis "StackExchange.Redis"
我只是想迁移到"ServiceStack.Redis"
我缺少什么?
在配置中使用密码
ConnectionMultiplexer.Connect("localhost,password=XXXXX");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.