I have a nice little class that works like a cache. Each item has a TimeSpan or DateTime expiration date. Each time an attempt is made to access an item in the cache, the item expires, and if it expired, the item is deleted from the cache and nothing is returned.
This is great for frequently accessed objects, but if an item is cached and never reopened, it is never deleted, even if it has expired.
What is a good methodology for expiring such items from the cache?
Do I have to have a background thread endlessly listing every item in the cache to check if it has expired?
source
share