If a cache requires heavy computation or must be done once, use singleflight
: https://godoc.org/golang.org/x/sync/singleflight
If multiple goroutine requests the same item, only send one request, other goroutine blocked and the same result returned.
网友评论