pub struct BoundedCache<C> { /* private fields */ }Expand description
A cache wrapper that caps total memory consumption by byte count.
Memory is tracked as key.len() + value.len() for every live entry.
When inserting a new entry would exceed max_bytes, the oldest entries
(tracked in insertion order) are evicted until there is enough budget.
§Type parameters
C: an innerCache<Vec<u8>, Vec<u8>>implementation.
Implementations§
Source§impl<C> BoundedCache<C>
impl<C> BoundedCache<C>
Trait Implementations§
Source§impl<C> Cache<Vec<u8>, Vec<u8>> for BoundedCache<C>
impl<C> Cache<Vec<u8>, Vec<u8>> for BoundedCache<C>
Source§fn get(&mut self, key: &Vec<u8>) -> Option<&Vec<u8>>
fn get(&mut self, key: &Vec<u8>) -> Option<&Vec<u8>>
Look up
key, returning a reference to the value if present. Read moreSource§fn put_with_ttl(
&mut self,
key: Vec<u8>,
value: Vec<u8>,
ttl: Duration,
) -> Option<Vec<u8>>
fn put_with_ttl( &mut self, key: Vec<u8>, value: Vec<u8>, ttl: Duration, ) -> Option<Vec<u8>>
Source§fn remove(&mut self, key: &Vec<u8>) -> Option<Vec<u8>>
fn remove(&mut self, key: &Vec<u8>) -> Option<Vec<u8>>
Remove the entry associated with
key, returning its value if present. Read moreSource§fn peek(&self, key: &Vec<u8>) -> Option<&Vec<u8>>
fn peek(&self, key: &Vec<u8>) -> Option<&Vec<u8>>
Look up
key without updating access metadata (no promotion). Read moreAuto Trait Implementations§
impl<C> Freeze for BoundedCache<C>where
C: Freeze,
impl<C> RefUnwindSafe for BoundedCache<C>where
C: RefUnwindSafe,
impl<C> Send for BoundedCache<C>where
C: Send,
impl<C> Sync for BoundedCache<C>where
C: Sync,
impl<C> Unpin for BoundedCache<C>where
C: Unpin,
impl<C> UnsafeUnpin for BoundedCache<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for BoundedCache<C>where
C: UnwindSafe,
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