pub struct LockFreeCache { /* private fields */ }Expand description
Lock-free cache with LRU-like eviction based on access frequency This implementation uses DashMap for lock-free concurrent access and provides 2-4x better performance than traditional LRU cache
Implementations§
Source§impl LockFreeCache
impl LockFreeCache
Sourcepub fn new(max_size_bytes: usize) -> Self
pub fn new(max_size_bytes: usize) -> Self
Create a new lock-free cache with the specified maximum size in bytes
Sourcepub fn get(&self, key: &EKey) -> Option<Arc<Vec<u8>>>
pub fn get(&self, key: &EKey) -> Option<Arc<Vec<u8>>>
Get an item from the cache (returns Arc for zero-copy)
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn contains(&self, key: &EKey) -> bool
pub fn contains(&self, key: &EKey) -> bool
Check if a key exists in the cache without updating access stats
Sourcepub fn current_size(&self) -> usize
pub fn current_size(&self) -> usize
Get the current size of the cache in bytes
Auto Trait Implementations§
impl Freeze for LockFreeCache
impl !RefUnwindSafe for LockFreeCache
impl Send for LockFreeCache
impl Sync for LockFreeCache
impl Unpin for LockFreeCache
impl !UnwindSafe for LockFreeCache
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