You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
преди 4 години | |
---|---|---|
README.md | преди 4 години | |
hashring.go | преди 6 години | |
hashring_test.go | преди 8 години |
README.md
hashring
A golang consistent hashring
Install
go get golib.gaore.com/GaoreGo/hashring
Usage
// virtualSpots means virtual spots created by each node
nodeWeight := make(map[string]int)
nodeWeight["node1"] = 1
nodeWeight["node2"] = 1
nodeWeight["node3"] = 2
vitualSpots := 100
hash := NewHashRing(virtualSpots)
//add nodes
hash.AddNodes(nodeWeight)
//remove node
hash.RemoveNode("node3")
//add node
hash.AddNode("node3", 3)
//get key's node
node := hash.GetNode("key")