Enumerating Cache Items
System.Web.Caching.Cache object implements the IDictionary interface, hence we can retreive a list of cached item keys as follows:
protected ReadOnlyCollection GetCacheItemList()
{
List cacheItemList = new List(Cache.Count);
IDictionaryEnumerator cacheEnum = Cache.GetEnumerator();
while (cacheEnum.MoveNext())
{
DictionaryEntry cacheItem = (DictionaryEntry)cacheEnum.Current;
cacheItemList.Add(cacheItem.Key.ToString());
}
return new ReadOnlyCollection(cacheItemList);
}
