cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(rrs []dns.RR) string

Key uses the name, type and rdata, which is serialized and then hashed as the key for the lookup.

func QuestionKey

func QuestionKey(q dns.Question, dnssec bool) string

QuestionKey creates a hash key from a question section. It creates a different key for requests with DNSSEC.

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Cache is a LRU cache that holds on the a number of RRs or DNS messgas.

func New

func New(capacity, ttl int) *Cache

New returns a new cache with the capacity and the ttl specified.

func (*Cache) Capacity added in v1.0.2

func (c *Cache) Capacity() int

Capacity returns the capacity of the cache as an int.

func (*Cache) InsertMessage

func (c *Cache) InsertMessage(s string, msg *dns.Msg)

InsertMessage inserts a message in the Cache. We will cache it for ttl seconds, which should be a small (60...300) integer.

func (*Cache) InsertSignature

func (c *Cache) InsertSignature(s string, sig *dns.RRSIG)

InsertSignature inserts a signature, the expiration time is used as the cache ttl.

func (*Cache) Remove

func (c *Cache) Remove(s string)

Remove removes the element under key s from the cache.

func (*Cache) Search

func (c *Cache) Search(s string) (*dns.Msg, time.Time, bool)

Search returns .... and a boolean indicating if we found something in the cache.

func (*Cache) Size added in v1.0.2

func (c *Cache) Size() int

Size returns the size of the cache as an int.

Jump to

Keyboard shortcuts

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