4 ms·
sync.Map is NOT a good solution for all concurrent map use cases. Please use your best judgement for the well documented trade-offs: >The Map type is optimized
by jzelinskie 8y ago
sync.Map is NOT a good solution for all concurrent map use cases. Please use your best judgement for the well documented trade-offs:
>The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.