コード例 #1
0
 /// <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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 /// <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));
 }