cache

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(q dns.Question, dnssec, tcp bool) string

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

func KeyRRset added in v1.0.7

func KeyRRset(rrs []dns.RR) string

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

Types

type Cache

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

Cache is a cache that holds on the a number of RRs or DNS messages. The cache eviction is randomized.

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

func (*Cache) EvictRandom added in v1.0.7

func (c *Cache) EvictRandom()

EvictRandom removes a random member a the cache. Must be called under a write lock.

func (*Cache) Hit added in v1.0.7

func (c *Cache) Hit(question dns.Question, dnssec, tcp bool, msgid uint16) *dns.Msg

Hit returns a dns message from the cache. If the message's TTL is expired nil is returned and the message is removed from the cache.

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)

func (*Cache) Search

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

Search returns a dns.Msg, the expiration time and a boolean indicating if we found something in the cache.

Jump to

Keyboard shortcuts

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