Struct conhash::conhash::ConsistentHash
[−]
[src]
pub struct ConsistentHash<N: Node> { /* fields omitted */ }
Consistent Hash
Methods
impl<N: Node> ConsistentHash<N>
[src]
fn new() -> ConsistentHash<N>
Construct with default hash function (Md5)
fn with_hash(hash_fn: fn(_: &[u8]) -> Vec<u8>) -> ConsistentHash<N>
Construct with customized hash function
fn add(&mut self, node: &N, num_replicas: usize)
Add a new node
fn get<'a>(&'a self, key: &[u8]) -> Option<&'a N>
Get a node by key. Return None
if no valid node inside
fn get_str<'a>(&'a self, key: &str) -> Option<&'a N>
Get a node by string key
fn get_mut<'a>(&'a mut self, key: &[u8]) -> Option<&'a mut N>
Get a node by key. Return None
if no valid node inside
fn get_str_mut<'a>(&'a mut self, key: &str) -> Option<&'a mut N>
Get a node by string key
fn remove(&mut self, node: &N)
Remove a node with all replicas (virtual nodes)
fn len(&self) -> usize
Number of nodes