pub struct TtlCache { /* private fields */ }
Expand description
A more advanced cache with TTL (Time To Live) support.
Implementations§
Source§impl TtlCache
impl TtlCache
Sourcepub fn new(default_ttl: Duration, max_size: Option<usize>) -> Self
pub fn new(default_ttl: Duration, max_size: Option<usize>) -> Self
Create a new TTL cache with the specified TTL.
§Arguments
default_ttl
- The default time-to-live for cache entries.max_size
- Optional maximum size for the cache.
Sourcepub fn default_ttl(&self) -> Duration
pub fn default_ttl(&self) -> Duration
Get the default TTL.
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics.
Trait Implementations§
Source§impl BaseCache for TtlCache
impl BaseCache for TtlCache
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
Auto Trait Implementations§
impl Freeze for TtlCache
impl !RefUnwindSafe for TtlCache
impl Send for TtlCache
impl Sync for TtlCache
impl Unpin for TtlCache
impl !UnwindSafe for TtlCache
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