Cache Monitoring & Diagnostics
CacheExpose exposes a full diagnostics surface — typed snapshots, several pre-formatted report strings, a structured monitoring dictionary for dashboards, health alerts, and manual cache management methods.
Structured snapshots
Three typed objects describe the cache state at a moment in time:
| Method | Returns | Use for |
|---|---|---|
GetCacheStatistics() | CacheStatistics | Per-store entry counts, hit / miss totals, eviction counters. |
GetCacheConfiguration() | CacheConfiguration | The currently active CacheOptions values. |
GetMemoryUsage() | CacheMemoryUsage | Real byte-level memory consumption per store (measured by CacheCalculator). |
Report generators
Four pre-formatted text reports for logs, debugger output, or admin endpoints:
| Method | Content |
|---|---|
GeneratePerformanceReport() | Hit rates, miss rates, eviction frequencies — the throughput view. |
GenerateCompactStatusReport() | One-paragraph summary suitable for log lines. |
GenerateCacheAnalysisReport() | Deeper analytical view — per-store breakdown, top entries. |
GetQuickHealthSummary() | One-line health status — green / amber / red. |
Structured monitoring data
For dashboards or metrics scrapers, GenerateMonitoringReport returns a Dictionary<string, object> with the same information in a structured form.
Health alerts
GenerateHealthAlerts(...) evaluates the cache against aHealthAlertsInput threshold object and returns a list of actionable alerts — for example "TypeProperties store is 95% full" or "Hit rate dropped below 50%."
Cache management
| Method | Effect |
|---|---|
ClearAllCaches() | Empties every store and resets all access tracking. |
ClearCache(CacheMemoryType) | Empties a single store — see CacheMemoryType. |
ForceEvictionOnAllCaches() | Runs the configured eviction strategy on every store immediately, regardless of current size. |
IsCacheFull(CacheMemoryType) | Returns true when the target store has reached MaxCacheSize. |
Note
Statistics and reports are read-only snapshots — calling them does not count as a cache access and will not affect LRU / LFU ordering.
Full example
Every API in one place:
// Get structured statistics
CacheStatistics stats = CacheExpose.GetCacheStatistics();
CacheConfiguration config = CacheExpose.GetCacheConfiguration();
CacheMemoryUsage memory = CacheExpose.GetMemoryUsage();
// Generate reports
string perfReport = CacheExpose.GeneratePerformanceReport();
string compactReport = CacheExpose.GenerateCompactStatusReport();
string analysisReport = CacheExpose.GenerateCacheAnalysisReport();
string healthSummary = CacheExpose.GetQuickHealthSummary();
// Monitoring data for dashboards
Dictionary<string, object> monitoringData = CacheExpose.GenerateMonitoringReport();
// Health alerts
var alerts = CacheExpose.GenerateHealthAlerts(new HealthAlertsInput { ... });
// Cache management
CacheExpose.ClearAllCaches();
CacheExpose.ClearCache(CacheMemoryType.PropertyPath);
CacheExpose.ForceEvictionOnAllCaches();
bool isFull = CacheExpose.IsCacheFull(CacheMemoryType.TypeProperties);