I would like to cache the n
most recent items using Microsoft.Extensions.Caching.Memory
. Once the cache size hits n
, the oldest item should be evicted to make room for the newest.
I can set the size limit like so:
use memoryCache = new MemoryCache(MemoryCacheOptions(SizeLimit = 10_000L))
But I’m not sure how to configure the eviction.
Can this be done? If so, how?