Versions in this module Expand all Collapse all v0 v0.1.0 Aug 30, 2026 Changes in this version + const DefaultMaxEntries + const DefaultPrefetchThreshold + const MaxShards + const StaleTTL + var ErrClosed = errors.New("cache: closed") + var ErrSweepInterval = errors.New("cache: sweep interval must be positive") + var ErrSweeperRunning = errors.New("cache: sweeper already running") + type Cache struct + func New(opts Options) (*Cache, error) + func (c *Cache) Bytes() int64 + func (c *Cache) Close() error + func (c *Cache) Flush() + func (c *Cache) FlushSubtree(n dnsmsg.Name) int + func (c *Cache) Get(q dnsmsg.Question, dnssecOK bool) (*dnsmsg.Message, Result) + func (c *Cache) Len() int + func (c *Cache) Put(m *dnsmsg.Message) bool + func (c *Cache) PutFor(q dnsmsg.Question, dnssecOK bool, m *dnsmsg.Message) bool + func (c *Cache) Reclaimed() uint64 + func (c *Cache) Remove(k Key) bool + func (c *Cache) SetRefresher(fn func(context.Context, Key)) + func (c *Cache) StartSweeper(ctx context.Context, interval time.Duration) error + func (c *Cache) Stats() Stats + func (c *Cache) Sweep() int + type Key struct + Class dnsmsg.Class + DNSSECOK bool + Name dnsmsg.Name + Type dnsmsg.Type + func KeyFor(q dnsmsg.Question, dnssecOK bool) Key + func (k Key) Question() dnsmsg.Question + func (k Key) String() string + type Options struct + Clock clock.Clock + Events *events.Bus + Logger *slog.Logger + MaxBytes int64 + MaxEntries int + MaxTTL time.Duration + Metrics metrics.Recorder + MinTTL time.Duration + NegativeTTL time.Duration + PrefetchThreshold float64 + ServeStale time.Duration + Shards int + func (o Options) Validate() error + type Reason string + const ReasonCacheable + const ReasonMetaType + const ReasonNoQuestion + const ReasonNoSOA + const ReasonNoTTL + const ReasonNotQuery + const ReasonNotResponse + const ReasonQuestionMismatch + const ReasonScopedECS + const ReasonTooLarge + const ReasonTransientRCode + const ReasonTruncated + const ReasonZeroTTL + func Cacheable(m *dnsmsg.Message) (bool, Reason) + type Result struct + Expires time.Time + Status Status + Stored time.Time + TTL uint32 + type Stats struct + Bytes int64 + Entries int + Evictions uint64 + Expired uint64 + Hits uint64 + Insertions uint64 + Misses uint64 + Refusals map[Reason]uint64 + StaleHits uint64 + func (s Stats) HitRate() float64 + type Status uint8 + const StatusExpired + const StatusHit + const StatusMiss + const StatusStale + func (s Status) String() string