/// <summary> /// This method acts as a proxy between the web and business components to check whether the /// underlying data has already been cached. /// </summary> /// <returns>List of Model.ProvinceCity from Cache or Business component</returns> public static List <Model.ProvinceCity> GetListProvinceCity() { BLL.ProvinceCity pcBll = new BLL.ProvinceCity(); if (!enableCaching) { return(pcBll.GetList()); } string key = "provinceCity_all"; List <Model.ProvinceCity> data = (List <Model.ProvinceCity>)HttpRuntime.Cache[key]; // Check if the data exists in the data cache if (data == null) { // If the data is not in the cache then fetch the data from the business logic tier data = pcBll.GetList(); // Create a AggregateCacheDependency object from the factory AggregateCacheDependency cd = DependencyFactory.GetProvinceCityDependency(); // Store the output in the data cache, and Add the necessary AggregateCacheDependency object HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(provinceCityTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
/// <summary> /// 获取当前根节点下的所有内容类型和内容 /// </summary> /// <param name="typeName"></param> /// <returns></returns> public static List <Model.ContentDetailInfo> GetSiteContent() { BLL.ContentDetail bll = new BLL.ContentDetail(); if (!enableCaching) { return(bll.GetSiteContent("站点所有帮助")); } string key = "sitecontent_all"; List <Model.ContentDetailInfo> data = (List <Model.ContentDetailInfo>)HttpRuntime.Cache[key]; if (data == null) { data = bll.GetSiteContent("站点所有帮助"); AggregateCacheDependency cd = DependencyFactory.GetProvinceCityDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(siteContentTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
public static List <Model.CategoryInfo> GetList() { BLL.Category bll = new BLL.Category(); if (!enableCaching) { return(bll.GetList()); } string key = "category_all"; List <Model.CategoryInfo> data = (List <Model.CategoryInfo>)HttpRuntime.Cache[key]; if (data == null) { data = bll.GetList(); AggregateCacheDependency cd = DependencyFactory.GetProvinceCityDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(categoryTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
public static List <string> GetKeywords() { BLL.SearchKeyword bll = new BLL.SearchKeyword(); if (!enableCaching) { return(bll.GetKeywords()); } string key = "keyword_all"; List <string> data = (List <string>)HttpRuntime.Cache[key]; if (data == null) { data = bll.GetKeywords(); AggregateCacheDependency cd = DependencyFactory.GetProvinceCityDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(keywordTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }