pub struct InMemoryCache { /* private fields */ }
Expand description
Cache that stores things in memory.
This is a simple in-memory cache implementation that stores cached values in a HashMap. It supports optional size limits and LRU eviction.
Implementations§
Source§impl InMemoryCache
impl InMemoryCache
Sourcepub fn with_max_size(max_size: Option<usize>) -> Self
pub fn with_max_size(max_size: Option<usize>) -> Self
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics.
Trait Implementations§
Source§impl BaseCache for InMemoryCache
impl BaseCache for InMemoryCache
Source§fn lookup(
&self,
prompt: &str,
llm_string: &str,
) -> Result<Option<CachedGenerations>>
fn lookup( &self, prompt: &str, llm_string: &str, ) -> Result<Option<CachedGenerations>>
Look up based on prompt and llm_string. Read more
Source§fn update(
&self,
prompt: &str,
llm_string: &str,
return_val: CachedGenerations,
) -> Result<()>
fn update( &self, prompt: &str, llm_string: &str, return_val: CachedGenerations, ) -> Result<()>
Update cache based on prompt and llm_string. Read more
Source§fn alookup<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
llm_string: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedGenerations>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn alookup<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
llm_string: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CachedGenerations>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Async look up based on prompt and llm_string. Read more
Source§fn aupdate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
llm_string: &'life2 str,
return_val: CachedGenerations,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn aupdate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
llm_string: &'life2 str,
return_val: CachedGenerations,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Async update cache based on prompt and llm_string. Read more
Source§impl Debug for InMemoryCache
impl Debug for InMemoryCache
Auto Trait Implementations§
impl Freeze for InMemoryCache
impl !RefUnwindSafe for InMemoryCache
impl Send for InMemoryCache
impl Sync for InMemoryCache
impl Unpin for InMemoryCache
impl !UnwindSafe for InMemoryCache
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