edit README.md
This commit is contained in:
parent
4f382af59b
commit
e161d799da
28
README.md
28
README.md
@ -13,26 +13,26 @@ Usage
|
|||||||
|
|
||||||
```
|
```
|
||||||
// virtualSpots means virtual spots created by each node
|
// virtualSpots means virtual spots created by each node
|
||||||
nodeWeight := make(map[string]int)
|
nodeWeight := make(map[string]int)
|
||||||
nodeWeight["node1"] = 1
|
nodeWeight["node1"] = 1
|
||||||
nodeWeight["node2"] = 1
|
nodeWeight["node2"] = 1
|
||||||
nodeWeight["node3"] = 2
|
nodeWeight["node3"] = 2
|
||||||
vitualSpots := 100
|
vitualSpots := 100
|
||||||
hash := NewHashRing(virtualSpots)
|
hash := NewHashRing(virtualSpots)
|
||||||
|
|
||||||
|
|
||||||
//add nodes
|
//add nodes
|
||||||
hash.AddNodes(nodeWeight)
|
hash.AddNodes(nodeWeight)
|
||||||
|
|
||||||
//remove node
|
//remove node
|
||||||
hash.RemoveNode("node3")
|
hash.RemoveNode("node3")
|
||||||
|
|
||||||
|
|
||||||
//add node
|
//add node
|
||||||
hash.AddNode("node3", 3)
|
hash.AddNode("node3", 3)
|
||||||
|
|
||||||
|
|
||||||
//get key's node
|
//get key's node
|
||||||
node := hash.GetNode("key")
|
node := hash.GetNode("key")
|
||||||
|
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user