CachingResolver is a [Resolver] that caches the results of lookups. It's required to be created with [NewCachingResolver].
| 263 | // CachingResolver is a [Resolver] that caches the results of lookups. It's |
| 264 | // required to be created with [NewCachingResolver]. |
| 265 | type 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. |
| 279 | func NewCachingResolver(r *UpstreamResolver) (cr *CachingResolver) { |
nothing calls this directly
no outgoing calls
no test coverage detected