MCPcopy Create free account
hub / github.com/erans/pgsqlite / get_cache_status

Function get_cache_status

src/cache/status.rs:17–36  ·  view source on GitHub ↗

Get current cache status

()

Source from the content-addressed store, hash-verified

15
16/// Get current cache status
17pub fn get_cache_status() -> CacheStatus {
18 let metrics = GLOBAL_QUERY_CACHE.get_metrics();
19 let (cache_size, _) = GLOBAL_QUERY_CACHE.stats();
20
21 let hit_rate = if metrics.total_queries > 0 {
22 (metrics.cache_hits as f64 / metrics.total_queries as f64) * 100.0
23 } else {
24 0.0
25 };
26
27 CacheStatus {
28 total_queries: metrics.total_queries,
29 cache_hits: metrics.cache_hits,
30 cache_misses: metrics.cache_misses,
31 hit_rate,
32 evictions: metrics.evictions,
33 cache_size,
34 cache_capacity: 1000, // From GLOBAL_QUERY_CACHE initialization
35 }
36}
37
38/// Format cache status as a PostgreSQL result set
39pub fn format_cache_status_as_table() -> (Vec<String>, DbRows) {

Callers 2

log_cache_statusFunction · 0.85

Calls 2

get_metricsMethod · 0.80
statsMethod · 0.45

Tested by

no test coverage detected