get returns a cached IP for host, or "" if missing/expired. Expired entries are evicted on access to keep the map small.
(host string)
| 32 | // get returns a cached IP for host, or "" if missing/expired. Expired entries |
| 33 | // are evicted on access to keep the map small. |
| 34 | func (c *dnsCache) get(host string) string { |
| 35 | c.mu.Lock() |
| 36 | defer c.mu.Unlock() |
| 37 | e, ok := c.entries[host] |
| 38 | if !ok { |
| 39 | return "" |
| 40 | } |
| 41 | if time.Now().After(e.expires) { |
| 42 | delete(c.entries, host) |
| 43 | return "" |
| 44 | } |
| 45 | return e.ip |
| 46 | } |
| 47 | |
| 48 | func (c *dnsCache) set(host, ip string) { |
| 49 | c.mu.Lock() |
no outgoing calls
no test coverage detected