SetIfAbsent adds the list for the specified key to the cache. If a list for the same key already exists, the cache will not be modified and the existing list will be returned instead. This behavior is meant to prevent the goroutines using the cache from ending up with an orphaned version of a list.
(key string, updated *List)
| 246 | // will be returned instead. This behavior is meant to prevent the goroutines |
| 247 | // using the cache from ending up with an orphaned version of a list. |
| 248 | func (lc *LocalCache) SetIfAbsent(key string, updated *List) *List { |
| 249 | lc.Lock() |
| 250 | defer lc.Unlock() |
| 251 | if pl, ok := lc.plists[key]; ok { |
| 252 | return pl |
| 253 | } |
| 254 | lc.plists[key] = updated |
| 255 | return updated |
| 256 | } |
| 257 | |
| 258 | func (lc *LocalCache) getInternal(key []byte, readFromDisk, readUids bool) (*List, error) { |
| 259 | skey := string(key) |