pub struct ResponseCache { /* private fields */ }Expand description
Simple LRU response cache
Implementations§
Source§impl ResponseCache
impl ResponseCache
pub fn new(max_entries: usize, _default_ttl: Duration) -> Self
Sourcepub fn get(&self, key: &CacheKey) -> Option<CachedResponse>
pub fn get(&self, key: &CacheKey) -> Option<CachedResponse>
Get cached response if available and not expired
Sourcepub fn put(&self, key: CacheKey, response: CachedResponse)
pub fn put(&self, key: CacheKey, response: CachedResponse)
Store response in cache
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Clear expired entries
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for ResponseCache
impl !RefUnwindSafe for ResponseCache
impl Send for ResponseCache
impl Sync for ResponseCache
impl Unpin for ResponseCache
impl UnsafeUnpin for ResponseCache
impl !UnwindSafe for ResponseCache
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