DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

Cache Configuration

There are three ways to configure the reflection cache. All three call the same CacheExpose.Configure(...) overload set — pick whichever style fits your codebase.

Namespaces

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

Option 1 — Use a preset

The fastest way: pick a named preset that matches your environment.

// Option 1: Use a preset
CacheExpose.Configure(CacheOptions.ForHighMemoryEnvironment());

Option 2 — Builder pattern

Pass an Action<CacheOptions> that mutates the defaults. Useful when you only want to tweak a few values.

// Option 2: Builder pattern
CacheExpose.Configure(options =>
{
    options.MaxCacheSize       = 2000;
    options.LeastUsedThreshold = 20;
    options.EvictionStrategy   = CacheEvictionStrategy.LFU;
});

Option 3 — Direct options object

Construct a CacheOptions instance yourself. Every property is explicit — the most readable choice when you're checking config into source control.

// Option 3: Direct object
CacheExpose.Configure(new CacheOptions
{
    MaxCacheSize       = 3000,
    LeastUsedThreshold = 15,
    MostUsedThreshold  = 85,
    EvictionStrategy   = CacheEvictionStrategy.LRU
});
Note
Configuration is eventually consistent. Calling Configure does not invalidate or resize existing entries — the new options take effect for every subsequent lookup and the next eviction pass.

When to call Configure

Call once at application startup, before any queries run. In ASP.NET Core that typically means inside Program.cs after building the host but before app.Run():

var app = builder.Build();

CacheExpose.Configure(CacheOptions.ForHighFrequencyAccess());

app.Run();