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
| Component | Responsibility |
|---|---|
CacheReflection | Core reflection operations with caching — turns a type or path lookup into a cache hit (or a fresh reflection call on miss). |
CacheDatabase | Thread-safe ConcurrentDictionary stores & per-entry access tracking (timestamps for LRU, hit counts for LFU). |
CacheEviction | The FIFO, LRU, and LFU eviction algorithms. Runs when a store crosses MaxCacheSize or when forced. |
CacheReporting | Renders statistics, memory usage, and performance reports — every report string and the monitoring dictionary come from here. |
CacheCalculator | Actual memory measurement — walks live cache entries to produce a real byte-level CacheMemoryUsage snapshot. |
CacheExpose | Public 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, CacheMemoryTypeFlow of a cached lookup
When a query asks for the resolved property path "Customer.Address.City", the components cooperate as follows:
CacheReflectionreceives the lookup request.- It asks
CacheDatabasefor the cached path — a hit returns immediately and records an access for LRU/LFU tracking. - On miss,
CacheReflectionperforms the real reflection, validates the path, normalises the casing, then writes the result back intoCacheDatabase. - If the store now exceeds
MaxCacheSize,CacheEvictionruns the configured algorithm to bring it back under threshold. CacheReportingandCacheCalculatorare read-only consumers ofCacheDatabase— they never mutate cache state.