System.Web.Caching.Cache object implements the IDictionary interface, hence we can retreive a list of cached item keys as follows:

[sourcecode lang=”csharp”] 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);
}

Post a Comment

Be the First to Comment!

wpDiscuz