// syncMapCache implements statCache, backed by a sync.Map type syncMapCache struct { src StatSource lookup sync.Map } func (smc *syncMapCache) get(name string) *statSet { val, _ := smc.lookup.Load(name) if set, ok := val.(*statSet); ok { return set } // create a new statSet, but don't store it if one was added since the last // load. This is not ideal since we can't atomically create the set and // write it. set, _ := smc.lookup.LoadOrStore(name, newStatSet(smc.src, name)) return set.(*statSet) }