vtcode_core/tools/registry/
cache.rs1use serde_json::json;
2
3use crate::tools::cache::FILE_CACHE;
4
5use super::ToolRegistry;
6
7impl ToolRegistry {
8 pub async fn cache_stats(&self) -> serde_json::Value {
9 let stats = FILE_CACHE.stats().await;
10 json!({
11 "hits": stats.hits,
12 "misses": stats.misses,
13 "entries": stats.entries,
14 "total_size_bytes": stats.total_size_bytes,
15 "hit_rate": if stats.hits + stats.misses > 0 {
16 stats.hits as f64 / (stats.hits + stats.misses) as f64
17 } else { 0.0 }
18 })
19 }
20
21 pub async fn clear_cache(&self) {
22 FILE_CACHE.clear().await;
23 }
24}