3

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.

Sean U
  • 6,730
  • 1
  • 24
  • 43

1 Answers1

0

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.

Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151