Packages

Maglev consistent hashing: a lookup table that spreads keys almost perfectly evenly across backends and stays stable when the backend set changes.

Current section

Files

Jump to
maglev CHANGELOG.md
Raw

CHANGELOG.md

# Changelog
All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.1.0] - 2026-08-06
First release.
### Added
- `Maglev.new/2` builds a lookup table over a set of backends, with a
configurable prime table size and backend key encoding.
- `Maglev.lookup/2` and `Maglev.lookup_index/2` select a backend, the latter
for callers that have already hashed the key.
- `Maglev.slots/1`, `Maglev.backends/1`, `Maglev.entry_counts/1` and
`Maglev.size/1` expose the built table for inspection, monitoring and export
to an external datapath.
- `Maglev.table_sizes/0` lists prime table sizes.
- Weighted backends via the `:weights` option, taking a map or a one-argument
function, with `Maglev.weights/1` reporting what a table was built with.
### Notes
- Backends are sorted by encoded key before construction. The algorithm as
published fills slots in backend index order, which would otherwise make the
table depend on the order the backend list arrives in.
- Backends that encode to the same key are rejected, since the algorithm cannot
distinguish them.
- Weights are positive integers rather than floats, so that the arithmetic
deciding slot assignment is exact and cannot diverge between nodes.
- Every backend receives at least one slot, which takes precedence over the
requested weight ratio when a table is too small to express it.
[0.1.0]: https://github.com/thatsme/maglev_ex/releases/tag/v0.1.0