/// 刷新全部的区域信息 /// <summary> /// 刷新全部的区域信息 /// </summary> /// <returns></returns> private List <AreaInfo> RefreshAllAreaInfoList() { //获取缓存数据 GetData(DataCacheKey.AreaInfo_Province); GetData(DataCacheKey.AreaInfo_City); GetData(DataCacheKey.AreaInfo_County); //存储 List <AreaInfo> list = new List <AreaInfo>(); AppendAreaData(list, AreaInfo_Province.Values.ToArray(), 1); AppendAreaData(list, AreaInfo_City.Values.ToArray(), 2); AppendAreaData(list, AreaInfo_County.Values.ToArray(), 3); //缓存 当前晚上0点过期 DateTime date = DateTime.Today.AddDays(1); DataCacheHelper.SetCache("AllAreaInfoList", list, date, System.Web.Caching.Cache.NoSlidingExpiration); return(list); }
/// 缓存 /// <summary> /// 缓存 /// </summary> /// <param name="key"></param> /// <returns></returns> private Dictionary <string, DataRow> CacheData(DataCacheKey key) { Dictionary <string, DataRow> data = new Dictionary <string, DataRow>(); //当前晚上0点过期 DateTime date = DateTime.Today.AddDays(1); string keycol = ""; DataTable dt = GetDataFunc(key, out keycol); if (dt == null) { Loger.Log4Net.Info("查询出错,未缓存数据:" + key); return(data); } foreach (DataRow dr in dt.Rows) { data[dr[keycol].ToString()] = dr; } //缓存字典 DataCacheHelper.SetCache(key.ToString(), data, date, System.Web.Caching.Cache.NoSlidingExpiration); //缓存表 DataCacheHelper.SetCache(key.ToString() + "_Table", dt, date, System.Web.Caching.Cache.NoSlidingExpiration); return(data); }