pub struct DistributedCacheClient {
pub local_node: NodeId,
pub ring: ConsistentHash,
}Expand description
Per-node client that wraps a ConsistentHash ring and provides key
routing from the perspective of local_node.
Fields§
§local_node: NodeIdThe node this client represents.
ring: ConsistentHashShared ring (each client holds its own copy for isolation in this in-process model; in a real system this would be a shared reference).
Implementations§
Source§impl DistributedCacheClient
impl DistributedCacheClient
Sourcepub fn new(local_node: NodeId, ring: ConsistentHash) -> Self
pub fn new(local_node: NodeId, ring: ConsistentHash) -> Self
Create a new client for local_node with the given ring.
Sourcepub fn route_key(&self, key: &[u8]) -> NodeId
pub fn route_key(&self, key: &[u8]) -> NodeId
Determine which node should own key.
Returns local_node when the ring is empty (degenerate single-node
mode).
Sourcepub fn is_local_key(&self, key: &[u8]) -> bool
pub fn is_local_key(&self, key: &[u8]) -> bool
Return true if key maps to local_node (i.e. this node is the
primary owner).
Trait Implementations§
Source§impl Clone for DistributedCacheClient
impl Clone for DistributedCacheClient
Source§fn clone(&self) -> DistributedCacheClient
fn clone(&self) -> DistributedCacheClient
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 DistributedCacheClient
impl RefUnwindSafe for DistributedCacheClient
impl Send for DistributedCacheClient
impl Sync for DistributedCacheClient
impl Unpin for DistributedCacheClient
impl UnsafeUnpin for DistributedCacheClient
impl UnwindSafe for DistributedCacheClient
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