aspnet/Caching — pull request #4 by Tratcher (2014-09-03 19:23:08+00:00)
Title: Background expiration

Entries can become expired in the background due to any of the following reasons:
- Active trigger callbacks
- Passive triggers (no callbacks)
- Time based, absolute or sliding

Memory pressure triggers an event that removes 10% of entries, including all expired entries. Active trigger callbacks remove the associated entry immediately.

Until now, items that expired due to passive triggers or time would only be removed due to memory pressure or next time we tried to access them. This change adds a periodic check for expired items. There is no active timer running for the cache or individual entries. Instead the cache has two fields; the time of last scan, and the interval between scans. Any public interaction with the cache (Set, Get, Remove, or active trigger callback) will call StartScanForExpiredItems to see if a scan has run recently. If not it initiates a scan. This prevents timers from firing in idle applications, while still periodically removing expired items.

@GrabYourPitchforks @Eilon