doSetWithLockCheck performs a set operation with lock checking
(key string, val interface{})
| 207 | |
| 208 | // doSetWithLockCheck performs a set operation with lock checking |
| 209 | func (slm ShardLockMaps) doSetWithLockCheck(key string, val interface{}) (interface{}, bool) { |
| 210 | shard := slm.GetShard(key) |
| 211 | shard.Lock() |
| 212 | defer shard.Unlock() |
| 213 | |
| 214 | if got, ok := shard.items[key]; ok { |
| 215 | return got, false |
| 216 | } |
| 217 | |
| 218 | shard.items[key] = val |
| 219 | return val, true |
| 220 | } |
| 221 | |
| 222 | // doSetWithLockCheckWithFunc performs a set operation with function execution inside lock |
| 223 | func (slm ShardLockMaps) doSetWithLockCheckWithFunc(key string, f func(key string) interface{}) (interface{}, bool) { |
no test coverage detected