/// <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); } } } }