/// <summary> /// 清空cache /// </summary> public static void Clear() { IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator(); while (enumerator.MoveNext()) { CacheUtil.Remove(enumerator.Key.ToString()); } }
/// <summary> /// 根据规则删除cache /// </summary> /// <param name="pattern"></param> public static void RemoveByRegexp(string pattern) { if (pattern != "") { IDictionaryEnumerator enumerator = HttpContext.Current.Cache.GetEnumerator(); while (enumerator.MoveNext()) { string text = enumerator.Key.ToString(); if (Regex.IsMatch(text, pattern)) { CacheUtil.Remove(text); } } } }
/// <summary> /// 得到AppSettings中的配置字符串信息 /// </summary> /// <param name="key"></param> /// <returns></returns> public static string GetConfigString(string key) { string CacheKey = "AppSettings-" + key; object objModel = CacheUtil.Read(CacheKey); if (objModel == null) { try { objModel = ConfigurationManager.AppSettings[key]; if (objModel != null) { //DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(180), TimeSpan.Zero); CacheUtil.Insert(CacheKey, objModel, 60 * 180); } } catch { } } return(objModel.ToString()); }