Retrieves an element from map under given key.
(key string)
| 128 | |
| 129 | // Retrieves an element from map under given key. |
| 130 | func (m ConcurrentHashMap) Get(key string) (interface{}, bool) { |
| 131 | // Get shard |
| 132 | shard := m.GetShard(key) |
| 133 | shard.RLock() |
| 134 | // Get item from shard. |
| 135 | val, ok := shard.items[key] |
| 136 | shard.RUnlock() |
| 137 | return val, ok |
| 138 | } |
| 139 | |
| 140 | // Returns the number of elements within the map. |
| 141 | // 返回目前map中的数据总量 |