Ejemplo n.º 1
0
        /// <summary>
        /// 获取缓存数据
        /// </summary>
        /// <typeparam name="T">T泛型</typeparam>
        /// <returns></returns>
        protected IList <T> GetCacheList <T>() where T : class, new()
        {
            string cacheKey = typeof(T).Name;
            var    list     = MemberCacheHelper.Get(cacheKey).FromJSON <IList <T> >();

            if (list == null || list.Count <= 0)
            {
                list = GetEntitys <T>();
                MemberCacheHelper.Set(cacheKey, list.ToJSON());
            }
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 数据写入缓存
        /// </summary>
        /// <typeparam name="T">T泛型</typeparam>
        /// <returns></returns>
        protected bool CreateCache <T>() where T : class, new()
        {
            string cacheKey = typeof(T).Name;

            return(MemberCacheHelper.Set(cacheKey, GetEntitys <T>().ToJSON()));
        }