Skip to main content

Module metadata_cache

Module metadata_cache 

Source
Expand description

SQLite metadata cache for session files

Caches session metadata with mtime-based invalidation for 90% startup speedup.

Schema:

  • session_metadata table: stores parsed metadata + mtime + cache_version
  • Indexes: project, mtime for fast queries

Invalidation:

  • File watcher detects modification โ†’ delete cache entry
  • Startup: compare mtime โ†’ rescan if stale
  • Startup: compare cache_version โ†’ auto-clear if mismatch

Cache Version History:

  • v1: Initial version (pre-TokenUsage fix)
  • v2: Fixed TokenUsage::total() to include cache_read_tokens + cache_write_tokens
  • v3: Added token breakdown fields (input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens) to SessionMetadata + real pricing calculation

Structsยง

CacheStats
Cache statistics
MetadataCache
SQLite-based metadata cache (thread-safe)