Skip to main content

aa_cache/
lib.rs

1//! In-process **L1 cache** for the Agent Assembly storage layer.
2//!
3//! Policy is queried on the tool-call critical path, so a backend round-trip
4//! (Postgres or Gateway) per call is too expensive. [`L1Cache`] wraps any store
5//! behind an in-process [`DashMap`](dashmap::DashMap) with a configurable TTL and
6//! per-key stampede protection, so hot lookups hit memory and never cross the
7//! network.
8//!
9//! The wrapped store is abstracted by the [`CacheSource`] trait, which is
10//! blanket-implemented for [`aa_core::storage::PolicyStore`]; the cache itself is
11//! agnostic to which store it fronts.
12//!
13//! Invalidation (this is what the Epic C push-invalidation channel will call)
14//! is provided by [`L1Cache::invalidate`].
15
16mod cached_value;
17mod l1;
18mod source;
19
20#[cfg(any(test, feature = "test-utils"))]
21pub mod testing;
22
23pub use cached_value::CachedValue;
24pub use l1::L1Cache;
25pub use source::CacheSource;