DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

CacheEvictionStrategy

CacheEvictionStrategy selects the algorithm DynamicWhere.ex uses to evict entries from its internal reflection cache when a store reaches MaxCacheSize. It lives in DynamicWhere.ex.Optimization.Cache.Config.

Values

ValueDescription
FIFOFirst-In-First-Out. Predictable, minimal overhead — no per-access bookkeeping.
LRULeast Recently Used. Optimizes for temporal locality. (Default)
LFULeast Frequently Used. Optimizes for access-frequency patterns.

Trade-offs

StrategyBest forOverheadTracking
FIFOTesting, debugging, predictable behavior. Easy to reason about.Minimal — only insertion order.None per-access.
LRURecent-access-heavy workloads (admin dashboards, paginated browsing). Default for a reason — usually the right answer.Light — timestamp per access.EnableLruTracking auto-enabled.
LFUHot-set workloads where the same types/paths are hit repeatedly (high-frequency endpoints, type catalogs).Light — counter per access.EnableLfuTracking auto-enabled.
Note
Tracking flags are managed automatically based on the strategy you select. You normally don't need to touch EnableLruTracking or EnableLfuTracking directly.

C# usage

Builder pattern:

using DynamicWhere.ex.Optimization.Cache.Source;
using DynamicWhere.ex.Optimization.Cache.Config;

CacheExpose.Configure(options =>
{
    options.MaxCacheSize = 2000;
    options.LeastUsedThreshold = 20;
    options.EvictionStrategy = CacheEvictionStrategy.LFU;
});

Direct object:

CacheExpose.Configure(new CacheOptions
{
    MaxCacheSize = 3000,
    LeastUsedThreshold = 15,
    MostUsedThreshold = 85,
    EvictionStrategy = CacheEvictionStrategy.LRU
});

Presets that use each strategy

PresetStrategy
ForHighMemoryEnvironment()LRU
ForLowMemoryEnvironment()LFU
ForDevelopment()FIFO
ForHighFrequencyAccess()LFU
ForTemporalAccess()LRU