/// <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); }
/// <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())); }