pub struct ResultCache { /* private fields */ }Expand description
Cross-proposal cache for tool call results.
Implementations§
Source§impl ResultCache
impl ResultCache
Sourcepub async fn enable_caching(&self, tool: &str, ttl_secs: u64)
pub async fn enable_caching(&self, tool: &str, ttl_secs: u64)
Mark a tool as cacheable with a given TTL in seconds.
Sourcepub async fn get(&self, tool: &str, params: &Value) -> Option<Value>
pub async fn get(&self, tool: &str, params: &Value) -> Option<Value>
Return a cached result if the tool is cacheable and the entry is fresh.
Sourcepub async fn put(&self, tool: &str, params: &Value, result: Value)
pub async fn put(&self, tool: &str, params: &Value, result: Value)
Store a result in the cache. Only stores if the tool has caching enabled.
Sourcepub async fn invalidate(&self, tool: &str)
pub async fn invalidate(&self, tool: &str)
Clear all cached entries for a specific tool.
Sourcepub async fn invalidate_all(&self)
pub async fn invalidate_all(&self)
Clear all cached entries.
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Return hit/miss counts and current entry count.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResultCache
impl !RefUnwindSafe for ResultCache
impl Send for ResultCache
impl Sync for ResultCache
impl Unpin for ResultCache
impl UnsafeUnpin for ResultCache
impl !UnwindSafe for ResultCache
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