DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

CacheOptions

CacheOptions is the single configuration object for the reflection cache. Every tunable lives here — size caps, eviction algorithm, tracking toggles, and the auto-validation safety net.

Properties

PropertyTypeDefaultDescription
MaxCacheSizeint1000Maximum number of entries each store will hold before an eviction pass runs.
LeastUsedThresholdint25Percentage of entries to remove on a single eviction pass — the "least valuable" slice.
MostUsedThresholdint75Percentage of entries to keep — always equal to 100 − LeastUsedThreshold.
EvictionStrategyCacheEvictionStrategyLRUAlgorithm used to pick the least-valuable entries: FIFO, LRU, or LFU.
EnableLruTrackingbooltrueTracks per-entry access timestamps. Auto-managed based on EvictionStrategy.
EnableLfuTrackingboolfalseTracks per-entry hit counters. Auto-managed based on EvictionStrategy.
AutoValidateConfigurationbooltrueAuto-corrects mismatched settings — e.g. enables EnableLfuTracking when EvictionStrategy = LFU.
Note
LeastUsedThreshold and MostUsedThreshold always sum to 100. Setting one updates the other when AutoValidateConfiguration is on (the default).

Defaults in code

The default options object is equivalent to CacheOptions.Default:

var defaults = new CacheOptions
{
    MaxCacheSize              = 1000,
    LeastUsedThreshold        = 25,
    MostUsedThreshold         = 75,
    EvictionStrategy          = CacheEvictionStrategy.LRU,
    EnableLruTracking         = true,
    EnableLfuTracking         = false,
    AutoValidateConfiguration = true,
};

Strategy ↔ tracking matrix

When AutoValidateConfiguration is on, the two tracking flags are kept consistent with EvictionStrategy so that you never run an LFU eviction over zero hit counters.

EvictionStrategyEnableLruTrackingEnableLfuTracking
FIFOfalsefalse
LRUtruefalse
LFUfalsetrue