How to inspect cache policies inside System.Runtime.Caching.ObjectCache?
It doesn't look to me that there is a way to retrieve the CacheItemPolicy once it's been added to the cache collection.
The best way around this is can think of is to cache the policy object along with the item you want to cache but just appending "Policy" to the key name so that you can later retrieve the policy. This obviously assumes you have control over actually adding the item to the cache in the first place. Example below:
public ActionResult Index()
{
string key = "Hello";
string value = "World";
var cache = MemoryCache.Default;
CacheItemPolicy policy = new CacheItemPolicy();
policy.AbsoluteExpiration = DateTime.Now.AddDays(1);
cache.Add(new CacheItem(key, value), policy);
cache.Add(new CacheItem(key + "Policy", policy), null);
CacheItem item = cache.GetCacheItem(key);
CacheItem policyItem = cache.GetCacheItem(key + "Policy");
CacheItemPolicy policy2 = policyItem.Value as CacheItemPolicy;
ViewBag.Message = key + " " + value;
return View();
}