一致性哈希库
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
梁 致源 75d08d97d6 更新 'README.md' 3 年前
README.md 更新 'README.md' 3 年前
hashring.go remove RWMutex init 6 年前
hashring_test.go add pkg 7 年前

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