dnscache

package module
v0.0.0-...-629999f Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

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
}

Cache provides a proactive and expiring caching layer for DNS queries. All public methods of Cache are threadsafe.

func New

func New(bufferSize int, cacheMaxTTL, cacheMissTTL time.Duration, lookup func(Context, dns.Question) []dns.RR) *Cache

New creates a DNS cache with the given DNS lookup function

func (*Cache) Clear

func (c *Cache) Clear()

Clear will remove all recorded answers from the cache.

func (*Cache) Expire

func (c *Cache) Expire(q dns.Question)

Expire will remove any answers to the given question from the cache.

func (*Cache) Insert

func (c *Cache) Insert(q dns.Question, rr []dns.RR)

Insert will insert the given resource records into the cache as a response. to the given question

func (*Cache) Lookup

func (c *Cache) Lookup(r Request)

Lookup will retrieve an answer for the given request from the cache if it is present and unexpired, otherwise it will attempt to retrieve the value via the cache's lookup function and cache the returned value.

func (*Cache) Stop

func (c *Cache) Stop()

Stop will shut down the cache's processor.

type Context

type Context struct {
	Event Event
	Start time.Time
	Data  interface{}
}

Context provides contextual information about a DNS lookup, including what event triggered the lookup, when the looup was started, and any additional data that was provided in the original request.

type Event

type Event uint8

Event identifies what kind of event has triggered the lookup.

const (
	// Query indicates that this event is the result of an external query.
	Query Event = iota

	// Renewal indicates that this event is the result of proactive record
	// renewal.
	Renewal
)

func (Event) String

func (e Event) String() string

type Request

type Request struct {
	Question     dns.Question
	Start        time.Time
	Data         interface{}
	ResponseChan chan []dns.RR
}

Request defines a DNS request to be processed by a Cache object.

Jump to

Keyboard shortcuts

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