In a .NET 4 MemoryCache
, is there a way to find when an item was last accessed? I'm sure it's being tracked internally, since CacheItemPolicy
has the SlidingExpiration
property. But I haven't been able to find anywhere to read it.
Big picture, I'm looking for a way to manually remove the oldest n entries from a cache.
It doesn't seems to be possible to obtain this information from the MemoryCache. You will have to use a wrapper on your items with a member for last-access-time and update it whenever an item is accessed.