CacheBehavior Enumeration

Possible behaviors of CacheTKey, TValue when the cache store is full and an element has to be removed.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public enum CacheBehavior

Members

RemoveOldestElement0

Represents an element removal strategy for a CacheTKey, TValue instance, where the oldest (firstly stored) element will be removed when a new element has to be stored and the cache is full (that is, when Count reaches Capacity).

This is the suggested behavior when loading a non-cached element is very fast, or when firstly added elements are typically not retrieved again, or when cache is never full.

With this strategy element access is slightly faster than in case of RemoveLeastRecentUsedElement because no extra administration is required.

RemoveLeastRecentUsedElement1

Represents an element removal strategy for a CacheTKey, TValue instance, where the least recent used element will be removed when a new element has to be stored and the cache is full (that is, when Count reaches Capacity).

This is the suggested behavior when loading a non-cached element is slow, the cache is often full, and there are elements that are typically accessed more often than the others. This is the default behavior when a CacheTKey, TValue instance is instantiated.

With this strategy element is access is slightly slower than in case of RemoveOldestElement because whenever an element is accessed, it is renewed in the evaluation order. (See also the Touch. method)

See Also