/// <summary> /// 添加用户到缓存 /// </summary> /// <param name="company"></param> internal static void AddCachedCompany(Company company) { HHCache.Instance.Insert(CacheKeyManager.GetCompanyKey(company.CompanyID), company); HHCache.Instance.Insert(CacheKeyManager.GetCompanyKey(company.CompanyName), company); }
public static Company GetCompany(int companyID, string companyName, bool useCache) { Company company = null; string cacheKey = (companyID > 0) ? CacheKeyManager.GetCompanyKey(companyID) : CacheKeyManager.GetCompanyKey(companyName); if (useCache) { if (HttpContext.Current != null) { company = HttpContext.Current.Items[cacheKey] as Company; } if (company != null) { return(company); } company = HHCache.Instance.Get(cacheKey) as Company; } if (company == null) { company = CommonDataProvider.Instance.GetCompany(companyID, companyName); if (!useCache) { return(company); } if (HttpContext.Current != null) { HttpContext.Current.Items[cacheKey] = company; } AddCachedCompany(company); } return(company); }
/// <summary> /// 刷新用户缓存信息 /// </summary> /// <param name="company"></param> internal static void RefreshCachedCompany(Company company) { HHCache.Instance.Remove(CacheKeyManager.GetCompanyKey(company.CompanyID)); HHCache.Instance.Remove(CacheKeyManager.GetCompanyKey(company.CompanyName)); }