MCPcopy
hub / github.com/AdguardTeam/dnsproxy / set

Method set

proxy/cache.go:331–344  ·  view source on GitHub ↗

set stores response and upstream for req in the cache. u and l must not be nil.

(req, m *dns.Msg, u upstream.Upstream, l *slog.Logger)

Source from the content-addressed store, hash-verified

329// set stores response and upstream for req in the cache. u and l must not be
330// nil.
331func (c *cache) set(req, m *dns.Msg, u upstream.Upstream, l *slog.Logger) {
332 item := c.respToItem(m, u, l)
333 if item == nil {
334 return
335 }
336
337 key := msgToKey(req)
338 packed := item.pack()
339
340 c.itemsLock.Lock()
341 defer c.itemsLock.Unlock()
342
343 c.items.Set(key, packed)
344}
345
346// setWithSubnet stores response and upstream with subnet in the cache. The
347// given subnet mask and IP address are used to calculate the cache key. u, n,

Callers 8

cacheRespMethod · 0.80
TestServeCachedFunction · 0.80
TestCacheDOFunction · 0.80
TestCacheCNAMEFunction · 0.80
TestCache_uncacheableFunction · 0.80
TestCacheExpirationFunction · 0.80
runMethod · 0.80
setAndGetCacheFunction · 0.80

Calls 4

respToItemMethod · 0.95
msgToKeyFunction · 0.85
packMethod · 0.80
SetMethod · 0.45

Tested by 7

TestServeCachedFunction · 0.64
TestCacheDOFunction · 0.64
TestCacheCNAMEFunction · 0.64
TestCache_uncacheableFunction · 0.64
TestCacheExpirationFunction · 0.64
runMethod · 0.64
setAndGetCacheFunction · 0.64