Posts Tagged ‘cache’

September 1, 2008 0

How To Clear All Items From Cache

By in Uncategorized

if (Cache.Count > 0) { string currentKey = string.Empty; System.Collections.IDictionaryEnumerator cacheContents = System.Web.HttpContext.Current.Cache.GetEnumerator(); Response.Write(string.Format(“Following {0} cache keys were cleared:”, Cache.Count)); while (cacheContents.MoveNext()) { currentKey = cacheContents.Key.ToString(); Response.Write(currentKey + “”); System.Web.HttpContext.Current.Cache.Remove(currentKey); } } else { Response.Write(“Nothing to clear. Cache is empty.”); }

Tags: ,