Skip to main content

Module cache

Module cache 

Source
Expand description

Unified caching system for VT Code

This module provides a consolidated caching framework that replaces the multiple duplicate cache implementations throughout the codebase.

Uses interior mutability with RwLock to allow &self methods, following the pattern from matklad’s “Caches in Rust” article.

Structs§

CacheEntry
Cache entry with metadata
CacheStats
Cache statistics with consistent structure across all cache types
ContextAwareCache
Context-aware cache that limits results to MAX_CONTEXT_ITEMS
UnifiedCache
Unified cache backend with configurable eviction policies

Enums§

EvictionPolicy

Constants§

DEFAULT_CACHE_TTL
Default TTL for cache entries (2 minutes for memory-constrained environments)
DEFAULT_MAX_CACHE_CAPACITY
Default maximum cache capacity (reduced from 10,000 to 1,000 for memory efficiency)
MAX_CONTEXT_ITEMS
Maximum number of items to return in context-limited operations

Traits§

CacheKey
Unified cache key trait for all cache types
CacheValue
Unified cache value trait

Functions§

create_cache_key
Helper function to create cache key from serializable data
estimate_json_size
Helper function to estimate JSON value size without allocation