Expand description
Versioned Inference Cache with Atomic KB Invalidation
Extends the basic InferenceCache with explicit version tracking per knowledge base.
When a knowledge base is updated, all cached inferences for that KB are atomically
invalidated in O(n) time, where n is the number of cached entries for that KB.
§Design
CacheKeyidentifies an inference result by goal hash, KB identity, and KB version.CacheEntrystores variable bindings, a TTL, and a hit counter.VersionedInferenceCacheis a concurrent, version-aware cache backed byRwLock<HashMap>.CacheStatstracks inserts/hits/misses/invalidations/evictions viaAtomicU64.
§Thread Safety
All public methods are &self (shared reference). Internal mutation is protected by
RwLock. CacheStats uses AtomicU64 with Relaxed ordering for performance —
exact ordering guarantees are not required for statistics counters.
Structs§
- Cache
Entry - A single cached inference result.
- Cache
Key - Composite key for a single cached inference result.
- Cache
Stats - Atomic statistics counters for
VersionedInferenceCache. - Cache
Stats Snapshot - A point-in-time snapshot of
CacheStats. - Versioned
Inference Cache - Concurrent, version-aware memoization cache for inference results.
Enums§
- Cache
Error - Errors that can occur when interacting with
VersionedInferenceCache.