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

Struct CachingResolver

upstream/resolver.go:265–276  ·  view source on GitHub ↗

CachingResolver is a [Resolver] that caches the results of lookups. It's required to be created with [NewCachingResolver].

Source from the content-addressed store, hash-verified

263// CachingResolver is a [Resolver] that caches the results of lookups. It's
264// required to be created with [NewCachingResolver].
265type CachingResolver struct {
266 // resolver is the underlying resolver to use for lookups.
267 resolver *UpstreamResolver
268
269 // mu protects cache and it's elements.
270 mu *sync.RWMutex
271
272 // cache is the set of resolved hostnames mapped to cached addresses.
273 //
274 // TODO(e.burkov): Use expiration cache.
275 cache map[string]*ipResult
276}
277
278// NewCachingResolver creates a new caching resolver that uses r for lookups.
279func NewCachingResolver(r *UpstreamResolver) (cr *CachingResolver) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected