DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

Cache Presets

CacheOptions ships with six factory presets that cover the common deployment shapes. Each one returns a fully-populated CacheOptions instance that you pass straight to CacheExpose.Configure(...).

All six presets

PresetMaxCacheSizeEvictionLeastUsed%Use case
Default1000LRU25%General purpose — sane balance for any app.
ForHighMemoryEnvironment()5000LRU10%Servers with ample RAM — large working set, gentle eviction.
ForLowMemoryEnvironment()250LFU40%Constrained environments — small footprint, aggressive eviction, keep only hot entries.
ForDevelopment()100FIFO50%Testing & debugging — fast turnover for predictable behaviour.
ForHighFrequencyAccess()2000LFU20%Repeated queries on the same types — biased toward retaining frequently-hit entries.
ForTemporalAccess()1500LRU25%Recent-access-heavy workloads — favours entries used in the recent past.
Note
Each preset returns a new CacheOptions instance, so you can mutate the result if you need a small adjustment on top of a preset baseline.

Per-preset usage

Default

// Default — equivalent to "do nothing", but explicit
CacheExpose.Configure(CacheOptions.Default);

ForHighMemoryEnvironment

// Big servers with plenty of RAM — keep a large working set
CacheExpose.Configure(CacheOptions.ForHighMemoryEnvironment());

ForLowMemoryEnvironment

// Tight memory budget — small cap, aggressive eviction, LFU
CacheExpose.Configure(CacheOptions.ForLowMemoryEnvironment());

ForDevelopment

// Dev / test — small cap, FIFO eviction for predictable timings
CacheExpose.Configure(CacheOptions.ForDevelopment());

ForHighFrequencyAccess

// Hot-set workload — many requests against the same handful of types
CacheExpose.Configure(CacheOptions.ForHighFrequencyAccess());

ForTemporalAccess

// Recent-access workload — sliding-window of property paths
CacheExpose.Configure(CacheOptions.ForTemporalAccess());

Tweak a preset

Presets return mutable objects, so you can adjust one or two values without writing the whole CacheOptions by hand:

var options = CacheOptions.ForHighMemoryEnvironment();
options.MaxCacheSize = 8000; // bump the cap, keep everything else
CacheExpose.Configure(options);