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)
| 329 | // set stores response and upstream for req in the cache. u and l must not be |
| 330 | // nil. |
| 331 | func (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, |