Documentation
¶
Overview ¶
Package cache stores upstream replies and serves them again until their TTL runs out, counting TTLs down so clients see the true remaining time.
Rules:
- Only NOERROR and NXDOMAIN replies are cached, and never truncated ones.
- Positive answers live for the smallest TTL in the reply.
- Negative answers (NXDOMAIN, or NOERROR with no answer) live for min(SOA TTL, SOA MINIMUM), per RFC 2308 section 5. Without an SOA they are not cached.
- When full, the least recently used entry is evicted.
A nil *Cache is valid and caches nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func New ¶
New returns a cache holding at most maxEntries replies, none kept longer than maxTTL however long their records say.
func (*Cache) Get ¶
Get returns a cached reply rewritten for q: q's ID, q's question bytes (keeping the client's letter case), and TTLs reduced by the time spent in the cache. maxSize is the largest reply the client can receive; a cached reply bigger than that is not served.