package two import "sync" type sequenceCache struct { mu sync.RWMutex data map[sequence]int } func newSequenceCache() sequenceCache { return sequenceCache{ data: make(map[sequence]int), } } func (sc *sequenceCache) upsert(seq sequence, value int) { sc.mu.Lock() defer sc.mu.Unlock() sc.data[seq] += value }