导读: net(C )清空所有缓存Cache的方法
复制代码代码如下:
- ///
- /// 清空所有的Cache
- ///
- public static void ClearCache()
- {
- List<string> cacheKeys = new List<string>();
- IDictionaryEnumerator cacheEnum = HttpContext.Current.Cache.GetEnumerator();
- while (cacheEnum.MoveNext())
- {
- cacheKeys.Add(cacheEnum.Key.ToString());
- }
- foreach (string cacheKey in cacheKeys)
- {
- HttpContext.Current.Cache.Remove(cacheKey);
- }
- }