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