MCPcopy
hub / github.com/coredns/coredns / doPrefetch

Method doPrefetch

plugin/cache/handler.go:115–127  ·  view source on GitHub ↗
(ctx context.Context, cw *ResponseWriter, i *item, now time.Time)

Source from the content-addressed store, hash-verified

113}
114
115func (c *Cache) doPrefetch(ctx context.Context, cw *ResponseWriter, i *item, now time.Time) {
116 // Use a fresh metadata map to avoid concurrent writes to the original request's metadata.
117 ctx = metadata.ContextWithMetadata(ctx)
118 cachePrefetches.WithLabelValues(cw.server, c.zonesMetricLabel, c.viewMetricLabel).Inc()
119 c.doRefresh(ctx, cw.state, cw)
120
121 // When prefetching we loose the item i, and with it the frequency
122 // that we've gathered sofar. See we copy the frequencies info back
123 // into the new item that was stored in the cache.
124 if i1 := c.exists(cw.state.Name(), cw.state.QType(), cw.do, cw.cd); i1 != nil {
125 i1.Reset(now, i.Hits())
126 }
127}
128
129func (c *Cache) doRefresh(ctx context.Context, state request.Request, cw dns.ResponseWriter) (int, error) {
130 return plugin.NextOrFailure(c.Name(), c.Next, ctx, cw, state.Req)

Callers 1

tryPrefetchMethod · 0.95

Calls 7

doRefreshMethod · 0.95
existsMethod · 0.95
ContextWithMetadataFunction · 0.92
QTypeMethod · 0.80
HitsMethod · 0.80
NameMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected