ketama-hash-ring 11.2.0

Zero-dependency consistent hashing suite implementing Jump Consistent Hash, weighted Ketama virtual-node rings, and Google Maglev O(1) lookup tables.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented0 out of 0 items with examples
  • Size
  • Source code size: 40.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 300.0 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates-dev/ctares
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vshengbro

ketama-hash-ring

Zero-Dependency Jump Consistent Hash, Weighted Ketama Ring & Google Maglev Lookup Tables

Crates.io Version Docs.rs CI Status Rust 2024 License: MIT

Workspace Overview · API Docs


Overview

ketama-hash-ring implements zero-dependency Jump Consistent Hash (jump_consistent_hash), weighted Ketama virtual-node rings (ConsistentHashRing), and compact Google Maglev O(1) lookup tables (MaglevHash).

Installation

cargo add ketama-hash-ring

Usage

use ketama_hash_ring::{ConsistentHashRing, MaglevHash, jump_consistent_hash};

let mut ring = ConsistentHashRing::new(64);
ring.add_node("node-a", "10.0.0.1");
ring.add_node("node-b", "10.0.0.2");
let replicas = ring.get_replicas(b"user:42", 2);
assert_eq!(replicas.len(), 2);

let maglev = MaglevHash::with_table_size(vec![("node-a", 1usize), ("node-b", 2)], 65537);
assert!(maglev.get(b"user:42").is_some());
assert!(jump_consistent_hash(42, 8) < 8);

Verification

cargo run -p crate-cli -- fmt --check
cargo clippy -p ketama-hash-ring --all-features --all-targets -- -D warnings
cargo test -p ketama-hash-ring --all-features

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For inquiries, please contact the author at root@devhub.vip.