pub struct LruCache<K, V> { /* private fields */ }Available on crate feature
collections only.Expand description
A cache with a maximum capacity that evicts the least recently used items.
This implementation uses a Vec for order tracking, giving O(N) access
and insertion cost per operation. It is designed for small-capacity caches
(up to ~100 entries). For high-throughput or large-capacity use cases,
consider the lru crate which provides
O(1) operations via a doubly-linked list and HashMap.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for LruCache<K, V>
impl<K, V> RefUnwindSafe for LruCache<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for LruCache<K, V>
impl<K, V> Sync for LruCache<K, V>
impl<K, V> Unpin for LruCache<K, V>
impl<K, V> UnsafeUnpin for LruCache<K, V>
impl<K, V> UnwindSafe for LruCache<K, V>where
K: UnwindSafe,
V: 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