MCPcopy Index your code
hub / github.com/golang/groupcache / Add

Method Add

consistenthash/consistenthash.go:53–62  ·  view source on GitHub ↗

Add adds some keys to the hash.

(keys ...string)

Source from the content-addressed store, hash-verified

51
52// Add adds some keys to the hash.
53func (m *Map) Add(keys ...string) {
54 for _, key := range keys {
55 for i := 0; i < m.replicas; i++ {
56 hash := int(m.hash([]byte(strconv.Itoa(i) + key)))
57 m.keys = append(m.keys, hash)
58 m.hashMap[hash] = key
59 }
60 }
61 sort.Ints(m.keys)
62}
63
64// Get gets the closest item in the hash to the provided key.
65func (m *Map) Get(key string) string {

Callers 3

TestHashingFunction · 0.45
TestConsistencyFunction · 0.45
benchmarkGetFunction · 0.45

Calls

no outgoing calls

Tested by 3

TestHashingFunction · 0.36
TestConsistencyFunction · 0.36
benchmarkGetFunction · 0.36