(ctx context.Context, cw *ResponseWriter, i *item, now time.Time)
| 113 | } |
| 114 | |
| 115 | func (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 | |
| 129 | func (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) |
no test coverage detected