pub struct ResponseCache { /* private fields */ }Expand description
Thread-safe LRU response cache. get/insert take &self; the Mutex
guards the LruCache (whose get needs &mut to bump recency).
Implementations§
Source§impl ResponseCache
impl ResponseCache
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn get(&self, key: &str) -> Option<CacheEntry>
pub fn get(&self, key: &str) -> Option<CacheEntry>
Look up an entry, bumping its recency. Returns a clone so the lock is released before the caller inspects state / rebuilds a response.
pub fn insert(&self, key: String, entry: CacheEntry)
Sourcepub fn remove(&self, key: &str)
pub fn remove(&self, key: &str)
Drop a single key (used by an SWR refresh that produced an uncacheable
result, e.g. a 5xx — see should_cache).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
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