Monday, August 12, 2013

Configuring a sliding expiration on the System.Runtime.Caching.MemoryCache

One of the most useful caching configurations I use is a sliding expiration. This means that as long as an item in the cache is requested frequently, the item remains in the cache. This gives you a good balance between cache size and performance.

To configure this on the .NET MemoryCache you can use the following code:

No comments: