Пример #1
0
        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public long Publish(RedisChannel channel, RedisValue message)
        {
            var sub = _connMultiplexer.GetSubscriber();

            return(sub.Publish(channel, message));
        }
Пример #2
0
        /// <summary>
        /// 订阅
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="handle"></param>
        public void Subscribe(RedisChannel channel, Action <RedisChannel, RedisValue> handle)
        {
            var sub = _connMultiplexer.GetSubscriber();

            sub.Subscribe(channel, handle);
        }
Пример #3
0
        /// <summary>
        /// 发布(使用序列化)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task <long> PublishAsync <T>(RedisChannel channel, T message)
        {
            var sub = _connMultiplexer.GetSubscriber();

            return(await sub.PublishAsync(channel, Serialize(message)));
        }
Пример #4
0
        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task <long> PublishAsync(RedisChannel channel, RedisValue message)
        {
            var sub = _connMultiplexer.GetSubscriber();

            return(await sub.PublishAsync(channel, message));
        }
Пример #5
0
 /// <summary>
 /// 订阅
 /// </summary>
 /// <param name="channel"></param>
 /// <param name="handle"></param>
 public async Task SubscribeAsync(RedisChannel channel, Action <RedisChannel, RedisValue> handle)
 {
     var sub = _connMultiplexer.GetSubscriber();
     await sub.SubscribeAsync(channel, handle);
 }
Пример #6
0
        /// <summary>
        /// 发布(使用序列化)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public long Publish <T>(RedisChannel channel, T message)
        {
            var sub = _connMultiplexer.GetSubscriber();

            return(sub.Publish(channel, Serialize(message)));
        }