pub struct DataCache<K, V>{ /* private fields */ }Expand description
In-memory data cache
Implementations§
Source§impl<K, V> DataCache<K, V>
impl<K, V> DataCache<K, V>
pub fn new(config: CacheConfig) -> Self
Sourcepub fn get_with_state(&mut self, key: &K) -> Option<(&V, CacheState)>
pub fn get_with_state(&mut self, key: &K) -> Option<(&V, CacheState)>
Get a value and its state
Sourcepub fn insert(&mut self, key: K, value: V, options: CacheOptions)where
V: CacheSize,
pub fn insert(&mut self, key: K, value: V, options: CacheOptions)where
V: CacheSize,
Insert a value into cache
Sourcepub fn insert_default(&mut self, key: K, value: V)where
V: CacheSize,
pub fn insert_default(&mut self, key: K, value: V)where
V: CacheSize,
Insert with default options
Sourcepub fn invalidate_tag(&mut self, tag: &str) -> usize
pub fn invalidate_tag(&mut self, tag: &str) -> usize
Invalidate entries by tag
Sourcepub fn stats(&self) -> &CacheStats
pub fn stats(&self) -> &CacheStats
Get cache statistics
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get current memory usage
Sourcepub fn set_timestamp(&mut self, timestamp: u64)
pub fn set_timestamp(&mut self, timestamp: u64)
Set timestamp directly
Sourcepub fn on_event(&mut self, callback: CacheCallback)
pub fn on_event(&mut self, callback: CacheCallback)
Add event listener
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for DataCache<K, V>
impl<K, V> !RefUnwindSafe for DataCache<K, V>
impl<K, V> Send for DataCache<K, V>
impl<K, V> Sync for DataCache<K, V>
impl<K, V> Unpin for DataCache<K, V>
impl<K, V> !UnwindSafe for DataCache<K, V>
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
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().