[][src]Struct multicache::MultiCache

pub struct MultiCache<K, V> { /* fields omitted */ }

Methods

impl<K, V> MultiCache<K, V>[src]

pub fn new(bytesize: usize) -> MultiCache<K, V> where
    K: Hash + Eq
[src]

Create a new cache which will at most hold a total of bytesize in elements

pub fn put(&self, key: K, value: V, bytes: usize) where
    K: Hash + Eq
[src]

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

pub fn put_arc(&self, key: K, value: Arc<V>, bytes: usize) where
    K: Hash + Eq
[src]

Add a new element by key/Arc 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

pub fn get(&self, key: &K) -> Option<Arc<V>> where
    K: Hash + Eq
[src]

Get an element from the cache, updating it so it's now the most recently used and thus the last to be evicted

pub fn remove(&self, key: &K) -> Option<Arc<V>> where
    K: Hash + Eq
[src]

Remove an element from the cache, returning it if it exists

pub fn contains_key(&self, key: &K) -> bool where
    K: Hash + Eq
[src]

Check if a given key exists in the cache

Trait Implementations

impl<K: Debug, V: Debug> Debug for MultiCache<K, V>[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for MultiCache<K, V>

impl<K, V> Send for MultiCache<K, V> where
    K: Send,
    V: Send + Sync

impl<K, V> Sync for MultiCache<K, V> where
    K: Send,
    V: Send + Sync

impl<K, V> Unpin for MultiCache<K, V>

impl<K, V> UnwindSafe for MultiCache<K, V>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.