public static LoginInfo LoginInfo(string ID) { string key = LoginCacheName + ID; //if (!System.Web.HttpContext.Current.Request.Headers.AllKeys.Contains(key)) //{ // if (!CacheExtensions.CheckCache(key)) // { // var employee = MvcCore.Unity.Get<IEmployeeService>().Single(ID); // if (employee == null || employee.IsDisabled.GetValueOrDefault(false)) // { // Logout(); // throw new UnauthorizedAccessException("用户信息失效!"); // } // employee.ToLoginInfo().SetCache(); // } // System.Web.HttpContext.Current.Request.Headers.Set(key, CacheExtensions.GetCache<LoginInfo>(key).ToJson()); //} //return HttpContext.Current.Request.Headers.Get(key).FromJson<LoginInfo>(); if (!CacheExtensions.CheckCache(key)) { var employee = MvcBase.Unity.Get <IEmployeeService>().Single(ID); if (employee == null || employee.IsDisabled.GetValueOrDefault(false)) { Logout(); return(null); } employee.ToLoginInfo().SetCache(); } return(CacheExtensions.GetCache <LoginInfo>(key)); }
public virtual List <T> ListCache(string cacheName, CacheTimeType cacheTimeType, int cacheTime, Expression <Func <T, bool> > where, int count) { if (!CacheExtensions.CheckCache(cacheName)) { CacheExtensions.SetCache(cacheName, (object)this.dbset.AsNoTracking <T>().Where <T>(where).Take <T>(count).ToList <T>(), cacheTimeType, cacheTime); } return(CacheExtensions.GetCache <List <T> >(cacheName)); }
public virtual List <T> ListCache(string cacheName, CacheTimeType cacheTimeType, int cacheTime) { if (!CacheExtensions.CheckCache(cacheName)) { CacheExtensions.SetCache(cacheName, (object)this.dbset.AsNoTracking <T>().ToList <T>(), cacheTimeType, cacheTime); } return(CacheExtensions.GetCache <List <T> >(cacheName)); }