pub struct MultiCache<K, V> { /* private fields */ }
Implementations§
Source§impl<K, V> MultiCache<K, V>
impl<K, V> MultiCache<K, V>
Sourcepub fn new(bytesize: usize) -> MultiCache<K, V>
pub fn new(bytesize: usize) -> MultiCache<K, V>
Create a new cache which will at most hold a total of bytesize in elements
Sourcepub fn put(&self, key: K, value: V, bytes: usize)
pub fn put(&self, key: K, value: V, bytes: usize)
Add a new element by key/value with a given bytesize, if after inserting this element we would be going over the bytesize of the cache first enough elements are evicted for that to not be the case
Sourcepub fn put_arc(&self, key: K, value: Arc<V>, bytes: usize)
pub fn put_arc(&self, key: K, value: Arc<V>, bytes: usize)
Add a new element by key/Arc
Sourcepub fn get(&self, key: &K) -> Option<Arc<V>>
pub fn get(&self, key: &K) -> Option<Arc<V>>
Get an element from the cache, updating it so it’s now the most recently used and thus the last to be evicted
Trait Implementations§
Auto Trait Implementations§
impl<K, V> !Freeze for MultiCache<K, V>
impl<K, V> RefUnwindSafe for MultiCache<K, V>
impl<K, V> Send for MultiCache<K, V>
impl<K, V> Sync for MultiCache<K, V>
impl<K, V> Unpin for MultiCache<K, V>
impl<K, V> UnwindSafe for MultiCache<K, V>
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