pub struct LlmCache { /* private fields */ }Expand description
In-memory LLM response cache
Implementations§
Source§impl LlmCache
impl LlmCache
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new cache with default settings
- TTL: 1 hour
- Max size: 1000 entries
Sourcepub fn with_config(ttl: Duration, max_size: usize) -> Self
pub fn with_config(ttl: Duration, max_size: usize) -> Self
Create a new cache with custom settings
Sourcepub fn get(&self, request: &LlmRequest, model: &str) -> Option<LlmResponse>
pub fn get(&self, request: &LlmRequest, model: &str) -> Option<LlmResponse>
Get a cached response if it exists and hasn’t expired
Sourcepub fn put(&self, request: &LlmRequest, model: &str, response: LlmResponse)
pub fn put(&self, request: &LlmRequest, model: &str, response: LlmResponse)
Store a response in the cache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset hit/miss counters
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LlmCache
impl RefUnwindSafe for LlmCache
impl Send for LlmCache
impl Sync for LlmCache
impl Unpin for LlmCache
impl UnwindSafe for LlmCache
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