Add adds some keys to the hash.
(keys ...string)
| 51 | |
| 52 | // Add adds some keys to the hash. |
| 53 | func (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. |
| 65 | func (m *Map) Get(key string) string { |
no outgoing calls