[−][src]Struct memory_lru::MemoryLruCache
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]
&mut self,
key: &K,
with: impl FnOnce(Option<&mut V>) -> U
) -> U
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]
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for MemoryLruCache<K, V> where
K: Send,
V: Send,
[src]
K: Send,
V: Send,
impl<K, V> Sync for MemoryLruCache<K, V> where
K: Sync,
V: Sync,
[src]
K: Sync,
V: Sync,
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]
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,