This example seems to fetch data once, but I don't think it will invoke a fetchDataInBackground
function in background for each key
concurrently.
func Get(key string){
...
if itIsTheTimeToRefreshData{
var once sync.Once
onceBody := func() {
fetchDataInBackground()
}
go func() {
once.Do(onceBody)
}()
}
...
}
what I need to do is to assign each Once
instance to a key
so that all fetch data for different keys can be done concurrently.
how do I do that?