pub struct Cache<K> { /* private fields */ }
Expand description
A thread-safe concurrent cache from key K
to arbitrarily typed values
Implementations§
Source§impl<K: Hash + Eq> Cache<K>
impl<K: Hash + Eq> Cache<K>
Sourcepub fn new(num_pages: usize, page_size: usize) -> Self
pub fn new(num_pages: usize, page_size: usize) -> Self
Create a new cache setting page size and number of pages.
page_size
determines the maximum size of values that can be
stored in the cache.
num pages
determines how many slabs of memory of this size should be
allocated.
Each page has its own read-write lock, so the more pages you have, the less likely you are to have lock contention.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for Cache<K>
impl<K> !RefUnwindSafe for Cache<K>
impl<K> Unpin for Cache<K>where
K: Unpin,
impl<K> UnwindSafe for Cache<K>where
K: 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