func()

in groupcache.go [284:310]


func (g *Group) Get(ctx Context, key string, dest Sink) (*time.Time, error) {
	g.peersOnce.Do(g.initPeers)
	g.Stats.Gets.Add(1)
	if dest == nil {
		return nil, errors.New("groupcache: nil dest Sink")
	}
	payload, cacheHit := g.lookupCache(key)

	if cacheHit {
		g.Stats.CacheHits.Add(1)
		return payload.ttl, setSinkView(dest, payload.value)
	}

	// Optimization to avoid double unmarshalling or copying: keep
	// track of whether the dest was already populated. One caller
	// (if local) will set this; the losers will not. The common
	// case will likely be one caller.
	destPopulated := false
	payload, destPopulated, err := g.load(ctx, key, dest)
	if err != nil {
		return nil, err
	}
	if destPopulated {
		return payload.ttl, nil
	}
	return payload.ttl, setSinkView(dest, payload.value)
}