Browse Source

edit README.md

pull/2/head
g4zhuj 6 years ago
parent
commit
e161d799da
1 changed files with 14 additions and 14 deletions
  1. +14
    -14
      README.md

+ 14
- 14
README.md View File

@@ -13,26 +13,26 @@ 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)
nodeWeight := make(map[string]int)
nodeWeight["node1"] = 1
nodeWeight["node2"] = 1
nodeWeight["node3"] = 2
vitualSpots := 100
hash := NewHashRing(virtualSpots)
//add nodes
hash.AddNodes(nodeWeight)
//add nodes
hash.AddNodes(nodeWeight)
//remove node
hash.RemoveNode("node3")
//remove node
hash.RemoveNode("node3")

//add node
hash.AddNode("node3", 3)
//add node
hash.AddNode("node3", 3)

//get key's node
node := hash.GetNode("key")
//get key's node
node := hash.GetNode("key")

```

Loading…
Cancel
Save