This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
MemoryCache
Tratcher edited this page Oct 2, 2014
·
2 revisions
MemoryCache is intended to be a fast convenient way to store data that would otherwise be expensive to retrieve or generate. This is non-persistent lossy storage and should be used only as an optimization.
Items may be removed from the cache due to any of the following reasons:
- Explicit removal
- Absolute expiration - A specific time after which the entry is considered expired.
- Sliding expiration - An entry is considered expired if it is not accessed within a specified period of time. Each access renews this. An entry will not be renewed beyond the configured absolute expiration, if any.
- Triggers - A registered provider that notifies the cache when a given entry is expired.
- Memory pressure - The cache listens for Gen2 GC collections as an indication that the process is under memory pressure. When this occurs it will remove 10% of the current entries. Entries are removed in the following order:
- All expired entries
- Ordered by CachePreservationPriority
- Ordered by last access
- Linked entry expiration - Callers can create an EntryLink object to collect expiration data from one or more dependent entries and apply it to a new linked entry. Triggers and absolute expirations are copied as these indicate the associated value has become invalid. A linked entry is not considered expired if a dependent entry is removed explicitly, due to sliding expiration, or due to memory pressure, as these events are considered part of cache maintenance and do not directly reflect on validity of the values.