lru

package
v2.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CacheType = "lru"

Variables

View Source
var (
	ErrMaxEntriesNegative = errors.New("max entries is negative")
	ErrMaxEntriesZero     = errors.New("max entries is zero")
)

Functions

This section is empty.

Types

type LRU

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

func New

func New(settings Settings) (cache *LRU, err error)

func (*LRU) Add

func (l *LRU) Add(request, response *dns.Msg)

func (*LRU) Get

func (l *LRU) Get(request *dns.Msg) (response *dns.Msg)

type Metrics

type Metrics interface {
	SetCacheType(cacheType string)
	CacheInsertInc()
	CacheRemoveInc()
	CacheMoveInc()
	CacheGetEmptyInc()
	CacheInsertEmptyInc()
	CacheRemoveEmptyInc()
	CacheHitInc()
	CacheMissInc()
	CacheExpiredInc()
	CacheMaxEntriesSet(maxEntries int)
}

type Settings

type Settings struct {
	// MaxEntries is the maximum number of request<->response pairs
	// to be stored in the cache. It defaults to 10e4 if left unset.
	// Note its type is int insted of uint* since its maximum value
	// is math.MaxInt (it's used as an int length).
	MaxEntries int
	// Metrics is the metrics interface to record metric information
	// for the cache. It defaults to a No-Op metric implementation.
	Metrics Metrics
}

func (*Settings) SetDefaults

func (s *Settings) SetDefaults()

func (*Settings) String

func (s *Settings) String() string

func (*Settings) ToLinesNode

func (s *Settings) ToLinesNode() (node *gotree.Node)

func (Settings) Validate

func (s Settings) Validate() (err error)

Jump to

Keyboard shortcuts

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