pub struct ToolResultCache { /* private fields */ }Expand description
Tool result cache
Implementations§
Source§impl ToolResultCache
impl ToolResultCache
Sourcepub fn is_deterministic(&self, tool: &str) -> bool
pub fn is_deterministic(&self, tool: &str) -> bool
Check if tool is deterministic (cacheable)
Sourcepub fn mark_deterministic(&mut self, tool: impl Into<String>)
pub fn mark_deterministic(&mut self, tool: impl Into<String>)
Mark a tool as deterministic
Sourcepub fn mark_non_deterministic(&mut self, tool: &str)
pub fn mark_non_deterministic(&mut self, tool: &str)
Mark a tool as non-deterministic
Sourcepub fn set_tool_ttl(&self, tool: impl Into<String>, ttl: Duration)
pub fn set_tool_ttl(&self, tool: impl Into<String>, ttl: Duration)
Set custom TTL for a tool
Sourcepub fn get(&self, key: &ToolCallKey) -> Option<ToolResult>
pub fn get(&self, key: &ToolCallKey) -> Option<ToolResult>
Get cached result
Sourcepub fn put(&self, key: ToolCallKey, result: ToolResult)
pub fn put(&self, key: ToolCallKey, result: ToolResult)
Cache a tool result
Sourcepub async fn execute_with_cache<F, Fut>(
&self,
tool: &str,
params: &Value,
executor: F,
) -> ToolResult
pub async fn execute_with_cache<F, Fut>( &self, tool: &str, params: &Value, executor: F, ) -> ToolResult
Execute with caching
Sourcepub fn clear_tool(&self, tool: &str)
pub fn clear_tool(&self, tool: &str)
Clear cached results for a tool
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Remove expired entries
Sourcepub fn stats(&self) -> ToolCacheStatsSnapshot
pub fn stats(&self) -> ToolCacheStatsSnapshot
Get statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ToolResultCache
impl !RefUnwindSafe for ToolResultCache
impl Send for ToolResultCache
impl Sync for ToolResultCache
impl Unpin for ToolResultCache
impl UnsafeUnpin for ToolResultCache
impl UnwindSafe for ToolResultCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more