Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
Backend is the interface for a cache backend. All write operations in a Cache are forwarded to a Backend.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a cache of DNS messages.
func New ¶
New creates a new cache of given capacity.
If client is non-nil, the cache will prefetch expired entries in an effort to serve results faster.
If backend is non-nil:
- All cache write operations will be forward to the backend. - The backed will be used to pre-populate the cache.
func NewWithBackend ¶
NewWithBackend creates a new cache that forwards entries to backend.
func (*Cache) Set ¶
Set associates key with the DNS message msg.
If prefetching is disabled, the message will be evicted from the cache according to its TTL.
If prefetching is enabled, the message will never be evicted, but it will be refreshed when its TTL passes.
Setting a new key in a cache that has reached its capacity will evict values in a FIFO order.
type Value ¶
Value wraps a DNS message stored in the cache.