pub struct GenericTrackingCopyCache<M: Copy + Debug> { /* private fields */ }Expand description
Keeps track of already accessed keys. We deliberately separate cached Reads from cached mutations because we want to invalidate Reads’ cache so it doesn’t grow too fast.
Implementations§
Source§impl<M: Meter<Key, StoredValue> + Copy + Default> GenericTrackingCopyCache<M>
impl<M: Meter<Key, StoredValue> + Copy + Default> GenericTrackingCopyCache<M>
Sourcepub fn new(max_cache_size: usize, meter: M) -> GenericTrackingCopyCache<M>
pub fn new(max_cache_size: usize, meter: M) -> GenericTrackingCopyCache<M>
Creates instance of TrackingCopyCache with specified max_cache_size,
above which least-recently-used elements of the cache are invalidated.
Measurements of elements’ “size” is done with the usage of Meter
instance.
Sourcepub fn new_default(max_cache_size: usize) -> GenericTrackingCopyCache<M>
pub fn new_default(max_cache_size: usize) -> GenericTrackingCopyCache<M>
Creates instance of TrackingCopyCache with specified max_cache_size, above which
least-recently-used elements of the cache are invalidated. Measurements of elements’ “size”
is done with the usage of default Meter instance.
Sourcepub fn insert_read(&mut self, key: Key, value: StoredValue)
pub fn insert_read(&mut self, key: Key, value: StoredValue)
Inserts key and value pair to Read cache.
Sourcepub fn insert_write(&mut self, key: Key, value: StoredValue)
pub fn insert_write(&mut self, key: Key, value: StoredValue)
Inserts key and value pair to Write/Add cache.
Sourcepub fn insert_prune(&mut self, key: Key)
pub fn insert_prune(&mut self, key: Key)
Inserts key and value pair to Write/Add cache.
Sourcepub fn get(&mut self, key: &Key) -> Option<&StoredValue>
pub fn get(&mut self, key: &Key) -> Option<&StoredValue>
Gets value from key in the cache.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for GenericTrackingCopyCache<M>where
M: Freeze,
impl<M> RefUnwindSafe for GenericTrackingCopyCache<M>where
M: RefUnwindSafe,
impl<M> Send for GenericTrackingCopyCache<M>where
M: Send,
impl<M> Sync for GenericTrackingCopyCache<M>where
M: Sync,
impl<M> Unpin for GenericTrackingCopyCache<M>where
M: Unpin,
impl<M> UnwindSafe for GenericTrackingCopyCache<M>where
M: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more