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!
0
How to use goroutines in Go5
Write a Go program that prints 1 if test is true, and 0 otherwise.2
What is the equivalent of undefined in Go?0
Write a Go program that prints the following lines to the console: line 1, line 2, line 3, line 41
Iterate over a slice in Go0
Write a Go program that prints the numbers from 1 to 100
Write a Go program that prints the string "Hello World" to the console.