package main import ( "log" "sync" "time" "git.crumpington.com/public/toolbox/kvmemcache" ) func main() { N := 1024 * 2048 trigger := make(chan bool) c := kvmemcache.New(kvmemcache.Config{ MaxSize: 4, Src: func(key string) (interface{}, error) { <-trigger return key, nil }, }) readyGroup := sync.WaitGroup{} doneGroup := sync.WaitGroup{} readyGroup.Add(N) doneGroup.Add(N) for i := 0; i < N; i++ { go func() { readyGroup.Done() c.Get("a") doneGroup.Done() }() } readyGroup.Wait() t0 := time.Now() trigger <- true doneGroup.Wait() dt := time.Since(t0) log.Printf("%v", dt) }