Пример #1
0
        /// <summary>
        /// 获取消息发布服务
        /// </summary>
        /// <param name="hostAndPort">端口和域名</param>
        /// <param name="password">登录密码</param>
        /// <returns></returns>
        public static RedisPubServer Parse(string hostAndPort, string password)
        {
            var config = new PubConfig {
                HostAndPort = hostAndPort, Password = password
            };

            return(new RedisPubServer(RedisBase.GetMultiplexer(config), config));
        }
Пример #2
0
 /// <summary>
 /// 消息发布服务
 /// </summary>
 /// <param name="multiplexer">连接上下文</param>
 /// <param name="config">配置</param>
 private RedisPubServer(ConnectionMultiplexer multiplexer, PubConfig config)
 {
     this.multiplexer = multiplexer;
     this.server      = multiplexer.GetServer(config.HostAndPort);
     if (this.IsConnected)
     {
         this.info = this.server
                     .Info()
                     .SelectMany(item => item)
                     .ToDictionary((kv) => kv.Key, (kv) => kv.Value, StringComparer.OrdinalIgnoreCase);
     }
     this.Config = config;
 }
Пример #3
0
        /// <summary>
        /// 获取连接对象
        /// </summary>
        /// <param name="pubConfig">配置</param>
        /// <returns></returns>
        public static ConnectionMultiplexer GetMultiplexer(PubConfig pubConfig)
        {
            var config = pubConfig.ToString();

            return(Multiplexer.GetMultiplexer(config));
        }
Пример #4
0
 /// <summary>
 /// 获取消息发布服务
 /// </summary>
 /// <param name="config">配置信息</param>
 /// <returns></returns>
 public static RedisPubServer Parse(PubConfig config)
 {
     return(new RedisPubServer(RedisBase.GetMultiplexer(config), config));
 }