SkillAgentSearch skills...

Hashring

this is a consistent hashring implemented by go

Install / Use

/learn @g4zhuj/Hashring
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

Related Skills

View on GitHub
GitHub Stars103
CategoryDevelopment
Updated1y ago
Forks33

Languages

Go

Security Score

65/100

Audited on Feb 19, 2025

No findings