fr
fr

Question from the Go test

Medium

You are optimizing a data structure that is massively read and very rarely written to. What is the best practice to improve the concurrency of this code?

type Cache struct {
	mu   sync.Mutex
	data map[string]string
}

func (c *Cache) Get(key string) string {
	c.mu.Lock()
	defer c.mu.Unlock()
	return c.data[key]
}
Author: WeLoveDevsStatus: PublishedQuestion not yet passed
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!