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
<div align="center">

<img src="https://devhub.vip/pages/docs/img/logo.png" alt="ketama-hash-ring logo" height="120">

# ketama-hash-ring

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

[![Crates.io Version](https://flat.badgen.net/crates/v/ketama-hash-ring)](https://crates.io/crates/ketama-hash-ring)
[![Docs.rs](https://img.shields.io/docsrs/ketama-hash-ring?style=flat-square)](https://docs.rs/ketama-hash-ring)
[![CI Status](https://img.shields.io/github/actions/workflow/status/crates-dev/ctares/rust.yml?branch=master&style=flat-square&label=CI)](https://github.com/crates-dev/ctares/actions/workflows/rust.yml)
[![Rust 2024](https://img.shields.io/badge/edition-2024-orange.svg?style=flat-square)](https://www.rust-lang.org)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](../LICENSE)

[Workspace Overview](../README.md) ยท [API Docs](https://docs.rs/ketama-hash-ring/latest/)

</div>

---

## 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

```sh
cargo add ketama-hash-ring
```

## Usage

```rust
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

```sh
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](../LICENSE) file for details.

## Contact

For inquiries, please contact the author at [root@devhub.vip](mailto:root@devhub.vip).