DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

Cache Architecture

The cache subsystem is split into six single-responsibility components. Only one of them — CacheExpose — is part of the public API; the other five are implementation details you can read about for context.

The six components

ComponentResponsibility
CacheReflectionCore reflection operations with caching — turns a type or path lookup into a cache hit (or a fresh reflection call on miss).
CacheDatabaseThread-safe ConcurrentDictionary stores & per-entry access tracking (timestamps for LRU, hit counts for LFU).
CacheEvictionThe FIFO, LRU, and LFU eviction algorithms. Runs when a store crosses MaxCacheSize or when forced.
CacheReportingRenders statistics, memory usage, and performance reports — every report string and the monitoring dictionary come from here.
CacheCalculatorActual memory measurement — walks live cache entries to produce a real byte-level CacheMemoryUsage snapshot.
CacheExposePublic API — the only class consumers interact with. Every method you can call on the cache lives here.
Note
CacheExpose is the only public surface. The other five types live in internal namespaces and may change without notice. Treat CacheExpose as the stable contract.

Namespaces

The public surface lives in two namespaces:

using DynamicWhere.ex.Optimization.Cache.Source;   // CacheExpose
using DynamicWhere.ex.Optimization.Cache.Config;   // CacheOptions, CacheEvictionStrategy, CacheMemoryType

Flow of a cached lookup

When a query asks for the resolved property path "Customer.Address.City", the components cooperate as follows:

  1. CacheReflection receives the lookup request.
  2. It asks CacheDatabase for the cached path — a hit returns immediately and records an access for LRU/LFU tracking.
  3. On miss, CacheReflection performs the real reflection, validates the path, normalises the casing, then writes the result back into CacheDatabase.
  4. If the store now exceeds MaxCacheSize, CacheEviction runs the configured algorithm to bring it back under threshold.
  5. CacheReporting and CacheCalculator are read-only consumers of CacheDatabase — they never mutate cache state.