pub struct InMemoryToolCache { /* private fields */ }Expand description
A simple in-memory ToolCache backed by a Mutex<HashMap>.
Caches tool results keyed on (tool_name, args_json_string).
Optionally bounded by a maximum number of entries; the oldest entry is
evicted once the cap is exceeded.
§Example
ⓘ
use std::sync::Arc;
use llm_agent_runtime::agent::{InMemoryToolCache, ToolRegistry};
let cache = Arc::new(InMemoryToolCache::new());
let registry = ToolRegistry::new().with_cache(cache);Implementations§
Source§impl InMemoryToolCache
impl InMemoryToolCache
Sourcepub fn with_max_entries(max: usize) -> Self
pub fn with_max_entries(max: usize) -> Self
Create a cache that evicts the oldest entry once max entries are reached.
Sourcepub fn contains(&self, tool_name: &str, args: &Value) -> bool
pub fn contains(&self, tool_name: &str, args: &Value) -> bool
Return true if a cached result exists for (tool_name, args).
Trait Implementations§
Source§impl Debug for InMemoryToolCache
impl Debug for InMemoryToolCache
Source§impl Default for InMemoryToolCache
impl Default for InMemoryToolCache
Auto Trait Implementations§
impl !Freeze for InMemoryToolCache
impl RefUnwindSafe for InMemoryToolCache
impl Send for InMemoryToolCache
impl Sync for InMemoryToolCache
impl Unpin for InMemoryToolCache
impl UnsafeUnpin for InMemoryToolCache
impl UnwindSafe for InMemoryToolCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more