Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 1.06 KB

README.md

File metadata and controls

28 lines (22 loc) · 1.06 KB

hashring

Consistent hashing ring implementation. Useful for distributing cache among nodes.

How to use

import (
    "github.com/pabrodez/hashring"
)
// we are using a high replication factor as it ensures a lower standard deviation of the distribution of keys among nodes
nodeHashring := hashring.New([]string{"node1", "node2", "node3", 150})

nodeAddr := nodeHashring.GetNodeForKey("cacheKey")

nodeHashring.RemoveNode("node2")

nodeHashring.AddNode("node4")

References: