一致性哈希库
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
朱江 b84728bd22 add pkg 7 år sedan
README.md add pkg 7 år sedan
hashring.go add pkg 7 år sedan
hashring_test.go add pkg 7 år sedan

README.md

hashring

A golang consistent hashring

Install

go get github.com/g4zhuj/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")