Пример #1
0
        /// <summary>
        /// 异步保存数据DB文件到硬盘
        /// </summary>
        public static void SaveAsync()
        {
            IRedisClient Core;

            try
            {
                using  (Core = RedisManager.GetReadOnlyClient())
                {
                    Core.SaveAsync();
                }
            }
            catch (RedisException ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// 从链接池中获取一个只读连接,并执行对应的方法
        /// </summary>
        /// <typeparam name="F"></typeparam>
        /// <param name="doRead"></param>
        /// <returns></returns>
        public static F RedisRead <F>(Func <IRedisClient, F> doRead)
        {
            IRedisClient Core;

            try
            {
                using  (Core = RedisManager.GetReadOnlyClient())
                {
                    return(doRead(Core));
                }
            }
            catch (RedisException ex)
            {
                // return default(F);
                throw new Exception("Redis写入异常.Host:" + ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// 从链接池中获取一个连接,并执行对应的方法
        /// </summary>
        /// <typeparam name="F"></typeparam>
        /// <param name="doReadWrite">方法表达式</param>
        /// <returns></returns>
        public static F RedisPoolReadWrite <F>(Func <IRedisClient, F> doReadWrite)
        {
            IRedisClient Core;

            try
            {
                using  (Core = RedisManager.GetClient())
                {
                    return(doReadWrite(Core));
                }
            }
            catch (RedisException ex)
            {
                // return default(F);
                // throw new Exception("Redis写入异常.Host:" + Core.Host + ",Port:" + Core.Port);
                throw new Exception(ex.Message);
            }
        }
Пример #4
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public RedisSubscriber()
 {
     this.redisClient       = (RedisClient)RedisManager.GetClient();
     this.redisSubscription = new RedisSubscription(redisClient);
 }