一致性哈希库
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
梁 致源 75d08d97d6 更新 'README.md' il y a 3 ans
README.md 更新 'README.md' il y a 3 ans
hashring.go remove RWMutex init il y a 6 ans
hashring_test.go add pkg il y a 7 ans

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")