示例#1
0
        public IDatabase GetClient(RedisEndpoint endpoint, int connectTimeout)
        {
            var info = endpoint as RedisEndpoint;

            Check.NotNull(info, "endpoint");
            var key = string.Format("{0}{1}{2}{3}", info.Host, info.Port, info.Password, info.DbIndex);

            var point       = string.Format("{0}:{1}", info.Host, info.Port);
            var redisClient = ConnectionMultiplexer.Connect(new ConfigurationOptions()
            {
                EndPoints          = { { point } },
                ServiceName        = point,
                Password           = info.Password,
                ConnectTimeout     = connectTimeout,
                AbortOnConnectFail = false
            });

            return(redisClient.GetDatabase(info.DbIndex));
        }
示例#2
0
 public RedisProvider(RedisEndpoint endpoint, ICacheClient client)
 {
     KeySuffix    = endpoint.KeySuffix;
     _endpoint    = endpoint;
     _cacheClient = client;
 }