pub struct ToolCatalogCache { /* private fields */ }Expand description
Bounded LRU cache of (tool_set_identity) -> sha256_hex.
The cache key is a content-derived u64 hash of the tool list (length +
per-tool name + description + serialized input_schema). On a hit,
PrefixFingerprint::compute skips the per-tool JSON serialization and
the join — a workload that can be 100+ microseconds for a
60-tool catalog. On a miss, the work runs once and only the digest is
retained (#3854); the joined catalog string is ephemeral.
Implementations§
Source§impl ToolCatalogCache
impl ToolCatalogCache
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a cache that holds at most capacity tool-set entries.
Smaller values save memory at the cost of more cache misses.
Sourcepub fn fingerprint_for(&mut self, tools: &[Tool]) -> CachedCatalog
pub fn fingerprint_for(&mut self, tools: &[Tool]) -> CachedCatalog
Compute (or recall) the joined-and-hashed tool catalog for tools.
The cache is keyed on a content-derived u64 identity so two &[Tool]
slices with the same payloads — in the same order — hit the same entry.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Drop every cached entry. Used by tool-registry mutation paths (e.g. plugin hot-reload, MCP attach) when the caller cannot easily prove the tool set is unchanged.
Trait Implementations§
Source§impl Clone for ToolCatalogCache
impl Clone for ToolCatalogCache
Source§fn clone(&self) -> ToolCatalogCache
fn clone(&self) -> ToolCatalogCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more