pub struct StorageCache { /* private fields */ }Expand description
Multi-level cache for nodes and edges
Provides LRU-based caching with automatic eviction and TTL support. All operations are async and thread-safe.
Implementations§
Source§impl StorageCache
impl StorageCache
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new storage cache with default settings
Default configuration:
- Node cache: 10,000 entries
- Edge cache: 50,000 entries
- TTL: 5 minutes
Sourcepub fn with_capacity(node_capacity: u64, edge_capacity: u64) -> Self
pub fn with_capacity(node_capacity: u64, edge_capacity: u64) -> Self
Create a cache with custom capacities
Sourcepub async fn insert_node(&self, id: NodeId, node: Node)
pub async fn insert_node(&self, id: NodeId, node: Node)
Insert a node into cache
Sourcepub async fn invalidate_node(&self, id: &NodeId)
pub async fn invalidate_node(&self, id: &NodeId)
Remove a node from cache
Sourcepub async fn insert_edge(&self, id: EdgeId, edge: Edge)
pub async fn insert_edge(&self, id: EdgeId, edge: Edge)
Insert an edge into cache
Sourcepub async fn invalidate_edge(&self, id: &EdgeId)
pub async fn invalidate_edge(&self, id: &EdgeId)
Remove an edge from cache
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics
Returns current cache sizes. Note that hit/miss rates are not tracked by default in moka cache to minimize performance overhead.
Trait Implementations§
Source§impl Clone for StorageCache
impl Clone for StorageCache
Source§fn clone(&self) -> StorageCache
fn clone(&self) -> StorageCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StorageCache
impl !RefUnwindSafe for StorageCache
impl Send for StorageCache
impl Sync for StorageCache
impl Unpin for StorageCache
impl !UnwindSafe for StorageCache
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