Pop removes an element from the map and returns it
(key string)
| 167 | |
| 168 | // Pop removes an element from the map and returns it |
| 169 | func (slm ShardLockMaps) Pop(key string) (v interface{}, exists bool) { |
| 170 | shard := slm.GetShard(key) |
| 171 | shard.Lock() |
| 172 | v, exists = shard.items[key] |
| 173 | delete(shard.items, key) |
| 174 | shard.Unlock() |
| 175 | return v, exists |
| 176 | } |
| 177 | |
| 178 | // GetOrSet gets the value for the given key, or sets it if it doesn't exist. |
| 179 | // Returns the value and whether it was set (true) or already existed (false). |