class

JumpConsistentHasher(T)

Inherits Hasher < Reference < Object

Jump Consistent Hash implementation. Based on the paper "A Fast, Minimal Memory, Consistent Hash Algorithm" by John Lamping and Eric Veach (Google): https://arxiv.org/abs/1406.2294

Provides:

  • Perfect distribution (equal load across buckets)
  • Minimal disruption (only 1/n keys move when adding nth bucket)
  • O(ln n) time complexity
  • No memory overhead for storing a ring

Constructors

Instance methods

add(key : String, weight : UInt32, target : T)

Add a target to the hasher with the given key and weight. The weight determines how many "slots" or "virtual nodes" the target occupies.

Source
get(key : String) : T | Nil

Get the target for the given key, or nil if no targets exist.

Source
remove(key : String, weight : UInt32)

Remove a target from the hasher using its key and weight. The weight must match what was used when adding.

Source