Get all Cached Objects which are cached using MemoryCache class c#

YouKnowMe picture YouKnowMe · Jun 17, 2015 · Viewed 15.8k times · Source

I want to retrieve all the cache objects that are added using MemoryCache.

I tried the below but it is not retrieving them

System.Web.HttpContext.Current.Cache.GetEnumerator();
System.Web.HttpRuntime.Cache.GetEnumerator();

Note: Retreive all means not just what i know and created, i mean every cache object that gets created in the application.

Answer

YouKnowMe picture YouKnowMe · Jun 19, 2015

This is what i found (it may help some one)

foreach (var item in MemoryCache.Default)
{
   //add the item.keys to list
}
return list;