pub struct GhostNodeCache { /* private fields */ }Expand description
Cache of ghost nodes from other shards.
Ghost nodes are references to nodes that live on remote shards. This cache maintains a bounded set of ghost nodes using LRU eviction to keep frequently accessed nodes available while limiting memory usage.
§Example
ⓘ
use phago_distributed::shard::GhostNodeCache;
let mut cache = GhostNodeCache::new(100);
cache.insert(ghost_node);
if let Some(ghost) = cache.get(&node_id) {
println!("Found ghost node: {}", ghost.label);
}Implementations§
Source§impl GhostNodeCache
impl GhostNodeCache
Sourcepub fn new(max_size: usize) -> Self
pub fn new(max_size: usize) -> Self
Create a new ghost node cache with the specified maximum size.
§Arguments
max_size- Maximum number of ghost nodes to cache
Sourcepub fn peek(&self, id: &NodeId) -> Option<&GhostNode>
pub fn peek(&self, id: &NodeId) -> Option<&GhostNode>
Get a ghost node without updating LRU order (for read-only access).
Sourcepub fn insert(&mut self, ghost: GhostNode)
pub fn insert(&mut self, ghost: GhostNode)
Insert a ghost node into the cache.
If the cache is at capacity, the least recently used node will be evicted to make room.
§Arguments
ghost- The ghost node to insert
Sourcepub fn update_full_data(&mut self, id: &NodeId, data: NodeData)
pub fn update_full_data(&mut self, id: &NodeId, data: NodeData)
Update a ghost node with full data fetched from the remote shard.
§Arguments
id- The node ID to updatedata- The full node data
Sourcepub fn nodes_from_shard(&self, shard_id: ShardId) -> Vec<&GhostNode>
pub fn nodes_from_shard(&self, shard_id: ShardId) -> Vec<&GhostNode>
Sourcepub fn invalidate_shard(&mut self, shard_id: ShardId) -> usize
pub fn invalidate_shard(&mut self, shard_id: ShardId) -> usize
Sourcepub fn stats(&self) -> GhostCacheStats
pub fn stats(&self) -> GhostCacheStats
Get statistics about the cache.
Auto Trait Implementations§
impl Freeze for GhostNodeCache
impl RefUnwindSafe for GhostNodeCache
impl Send for GhostNodeCache
impl Sync for GhostNodeCache
impl Unpin for GhostNodeCache
impl UnsafeUnpin for GhostNodeCache
impl UnwindSafe for GhostNodeCache
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