How to get expiry date for cached item?

Viewed 20351

I store an object in MemoryCache:

void foo()
{
  ObjectCache cache = MemoryCache.Default;
  SomeClass obj = cache["CACHE_KEY"] as SomeClass;
  if (null == obj )
  {
     obj = new SomeClass(); ....
     CacheItemPolicy policy = new CacheItemPolicy();
     //update
     policy.AbsoluteExpiration = DateTime.Now+TimeSpan.FromMinutes(1);
     cache.Set("CACHE_KEY", obj, policy);
  }
  else
  {
     //get expiry date 
  }
  .....
}

Is it possible to get expiration date somehow if cache contains the object ?

2 Answers
Related