cache

package
v0.0.0-...-5abfbfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides an in-memory cache to store answers from remote DNS servers

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotFound       = errors.New("cache: node not found in tree")
	ErrNoSuchData         = errors.New("cache: no such data")
	ErrChildAlreadyExists = errors.New("cache: child already exists")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Lookup(string, uint16, uint16) ([]rr.RR, Status, error)

	LookupQuestion(dns.Question) ([]rr.RR, Status, error)

	Set(string, []rr.RR) error
}

Cache describes a cache interface to store RRs retrieved from remote DNS servers

type DefaultCache

type DefaultCache struct {
	*tree.Tree
	// contains filtered or unexported fields
}

DefaultCache implements the Cache interface and stores RRs in an in-memory tree

func NewDefaultCache

func NewDefaultCache(l *logger.Logger) *DefaultCache

NewDefaultCache returns a new default in-memory tree cache

func (*DefaultCache) Lookup

func (c *DefaultCache) Lookup(name string, class, t uint16) ([]rr.RR, Status, error)

Lookup looks up a entry for name with class and type and returns the status and errors encountered along the way

func (*DefaultCache) LookupQuestion

func (c *DefaultCache) LookupQuestion(message dns.Question) ([]rr.RR, Status, error)

LookupQuestion is a convenience function to lookup a DNS question

func (*DefaultCache) Set

func (c *DefaultCache) Set(name string, records []rr.RR) error

Set sets (or adds) a new cache entry

type Status

type Status int
const (
	Hit Status = iota
	Miss
	Expired
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL