예제 #1
0
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ItmeName"></param>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static CacheReturnData <T> GetCache <T>(string key)
        {
            CacheReturnData <T> cd = new CacheReturnData <T>();

            try
            {
                CacheModule cm = new CacheModule();
                if (cm.Exists(key))
                {
                    cd.data  = cm.Get <T>(key);
                    cd.reult = true;
                }
                else
                {
                    cd.reult = false;
                    cd.data  = default(T);
                }
            }
            catch
            {
                cd.reult = false;
                cd.data  = default(T);
            }
            return(cd);
        }
예제 #2
0
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="ItmeName"></param>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static CacheReturnData <T> SetCache <T>(T data, string key)
        {
            CacheReturnData <T> cd = new CacheReturnData <T>();

            try
            {
                CacheModule cm = new CacheModule();
                cd.reult = cm.Set(key, data);
                cd.data  = data;
            }
            catch
            {
                cd.reult = false;
                cd.data  = default(T);
            }
            return(cd);
        }
예제 #3
0
        public static CacheReturnData <Dictionary <string, string> > ServerModuleInfo()
        {
            CacheReturnData <Dictionary <string, string> > cd = new CacheReturnData <Dictionary <string, string> >();

            try
            {
                CacheModule cm = new CacheModule();
                cd.data  = cm.ServerInfo();
                cd.reult = true;
            }
            catch
            {
                cd.reult = false;
                cd.data  = new Dictionary <string, string>();
            }
            return(cd);
        }
예제 #4
0
        public static CacheReturnData <long> TryDelCache(string pattrm)
        {
            CacheReturnData <long> cd = new CacheReturnData <long>();

            try
            {
                CacheModule cm = new CacheModule();
                cd.data  = cm.Delete(pattrm);
                cd.reult = true;
            }
            catch
            {
                cd.reult = false;
                cd.data  = 0;
            }
            return(cd);
        }
예제 #5
0
        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="ItmeName"></param>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static CacheReturnData <long> DelCache(string key)
        {
            CacheReturnData <long> cd = new CacheReturnData <long>();

            try
            {
                CacheModule cm = new CacheModule();
                cd.data  = cm.Delete(key);
                cd.reult = true;
            }
            catch
            {
                cd.reult = false;
                cd.data  = -1;
            }
            return(cd);
        }
예제 #6
0
        /// <summary>
        /// 缓存统计
        /// </summary>
        /// <returns></returns>
        public static CacheReturnData <long> CacheCount()
        {
            CacheReturnData <long> cd = new CacheReturnData <long>();

            try
            {
                CacheModule cm = new CacheModule();
                cd.data  = cm.KeysNum();
                cd.reult = true;
            }
            catch
            {
                cd.reult = false;
                cd.data  = 0;
            }
            return(cd);
        }