[][src]Struct memory_lru::MemoryLruCache

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

An LRU-cache which operates on memory used.

Implementations

impl<K: Eq + Hash, V: ResidentSize> MemoryLruCache<K, V>[src]

pub fn new(max_size: usize) -> Self[src]

Create a new cache with a maximum cumulative size of values.

pub fn insert(&mut self, key: K, val: V)[src]

Insert an item.

pub fn get(&mut self, key: &K) -> Option<&V>[src]

Get a reference to an item in the cache. It is a logic error for its heap size to be altered while borrowed.

pub fn with_mut<U>(
    &mut self,
    key: &K,
    with: impl FnOnce(Option<&mut V>) -> U
) -> U
[src]

Execute a closure with the value under the provided key.

pub fn current_size(&self) -> usize[src]

Currently-used size of values in bytes.

Auto Trait Implementations

impl<K, V> RefUnwindSafe for MemoryLruCache<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe
[src]

impl<K, V> Send for MemoryLruCache<K, V> where
    K: Send,
    V: Send
[src]

impl<K, V> Sync for MemoryLruCache<K, V> where
    K: Sync,
    V: Sync
[src]

impl<K, V> Unpin for MemoryLruCache<K, V>[src]

impl<K, V> UnwindSafe for MemoryLruCache<K, V> where
    K: RefUnwindSafe + UnwindSafe,
    V: RefUnwindSafe + UnwindSafe
[src]

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.