dnscache

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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