memory

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultShards is the number of cache shards for concurrent access.
	// Higher values reduce lock contention but increase memory overhead.
	DefaultShards = 1024

	// DefaultLifeWindow is the maximum age of cached DNS responses.
	// After this duration, entries are evicted regardless of DNS TTL.
	DefaultLifeWindow = time.Minute

	// DefaultCleanWindow is the interval between cleanup cycles.
	// Lower values free memory faster but increase CPU usage.
	DefaultCleanWindow = 30 * time.Second

	// DefaultMaxEntriesInWindow estimates peak entries during LifeWindow.
	// Used for initial memory allocation (1000 entries/sec * 60 sec).
	DefaultMaxEntriesInWindow = 1000 * 10 * 60

	// DefaultMaxEntrySize is the maximum size of a single DNS message in bytes.
	// Larger responses will fail to cache. Typical DNS-over-UDP limit is 512 bytes.
	DefaultMaxEntrySize = 500
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(ctx context.Context) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Get

func (c *Cache) Get(key string) (*dns.Msg, error)

func (*Cache) Put

func (c *Cache) Put(key string, val *dns.Msg) error

Jump to

Keyboard shortcuts

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