Crates.io Circle CI

consist: Consistent Hashing in Rust

Consistent Hashing is a technique invented by David Karger and colleagues their 1997 paper Consistent Hashing and Random Trees. The original use case was to create a hashing scheme for cache servers so that the cache could be safely sharded over several nodes, which minimizing the amount of entries that would need to be shifted around when a node joins or leaves the network.

consist is a simple, zero-dependency library implementing Consistent Hashing in Rust.

Usage

Here is an example of usage of the library:

```rust extern crate consist;

use consist::HashRing;

[derive(Hash)]

struct Server(&'static str);

fn makecache() { let ring = HashRing::::new(); ring.addbucket(Server("10.0.1.1")); ring.addbucket(Server("10.0.1.2")); ring.addbucket(Server("10.0.1.3"));

// Search the cache
let url: &str = ...
let server = ring.get_bucket(str);
// Send a redirect to the cache server.

} ```