dnscache

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	Get(Key) *Value
	Add(Key, *Value)
	Purge()
}

Cacher is the interface for caching DNS response.

type Key

type Key struct {
	Qtype    uint16
	Qclass   uint16
	Name     string
	Upstream string
}

Key is the caching key for DNS message.

func NewKey

func NewKey(msg *dns.Msg, upstream string) Key

NewKey creates a new cache key for given DNS message.

type LRUCache

type LRUCache struct {
	// contains filtered or unexported fields
}

LRUCache implements Cacher interface.

func NewLRUCache

func NewLRUCache(size int) (*LRUCache, error)

NewLRUCache creates a new LRUCache instance with given size.

func (*LRUCache) Add

func (l *LRUCache) Add(key Key, value *Value)

Add adds a value to cache.

func (*LRUCache) Get

func (l *LRUCache) Get(key Key) *Value

Get looks up key's value from cache.

func (*LRUCache) Purge added in v1.3.6

func (l *LRUCache) Purge()

Purge clears the cache.

type Value

type Value struct {
	Expire time.Time
	Msg    *dns.Msg
}

func NewValue

func NewValue(msg *dns.Msg, expire time.Time) *Value

NewValue creates a new cache value for given DNS message.

Jump to

Keyboard shortcuts

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