queries

package
v0.0.0-...-f2271ba Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 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 Answered

type Answered struct {
	M *dns.Msg
	T time.Time
}

Answered for storing dns replies with TTL

type Queries

type Queries struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Queries for storing dns answers

func NewCache

func NewCache(ttl int) *Queries

NewCache creates a new empty cache

func (*Queries) Delete

func (c *Queries) Delete(h string)

Delete (blocking) for deleting a question from cache

func (*Queries) DeleteNX

func (c *Queries) DeleteNX(h string)

DeleteNX (blocking) for deleting a question from NX cache

func (*Queries) Exists

func (c *Queries) Exists(q string) bool

Exists (blocking) returns true if a question is in cache

func (*Queries) ExistsNX

func (c *Queries) ExistsNX(q string) bool

ExistsNX (blocking) returns true if a question is in NX cache

func (*Queries) ExpiredMXQueries

func (c *Queries) ExpiredMXQueries() []string

ExpiredMXQueries (blocking) for returning all expired NX questions. Returns empty slice if c.ttl is < 0

func (*Queries) ExpiredQueries

func (c *Queries) ExpiredQueries() []string

ExpiredQueries (blocking) for returning all expired questions. Returns empty slice if c.ttl is < 0

func (*Queries) Get

func (c *Queries) Get(s string) *dns.Msg

Get for getting a cached question from the cache

func (*Queries) GetTTL

func (c *Queries) GetTTL() int

GetTTL return cache.ttl value

func (*Queries) HasExpired

func (c *Queries) HasExpired(s string) bool

HasExpired for checking if a specific question in cache has expired

func (*Queries) HasExpiredNX

func (c *Queries) HasExpiredNX(s string) bool

HasExpiredNX for checking if a specific question in NX cache has expired

func (*Queries) NewNX

func (c *Queries) NewNX()

NewNX replaces current cache.nx map with a new map by copying all the elements. See cache.NewResolved for additional information

func (*Queries) NewResolved

func (c *Queries) NewResolved()

NewResolved replaces current cache.resolved map with a new map by copying all the elements. We this to free up memory, since the allocated memory by cache.resolved is that that the map had at its peak

func (*Queries) Question

func (c *Queries) Question(msg *dns.Msg) string

Question returns dns.Msg.Question[0].Name from a given dns message

func (*Queries) Register

func (c *Queries) Register(s string, msg *dns.Msg) bool

Register (blocking) for adding a new question to cache

func (*Queries) RegisterNX

func (c *Queries) RegisterNX(s string) bool

RegisterNX (blocking) for adding a new question to NX cache

func (*Queries) Renew

func (c *Queries) Renew(s string, msg *dns.Msg) bool

Renew (blocking) for updating ttl for a question in cache

func (*Queries) RenewNX

func (c *Queries) RenewNX(s string) bool

RenewNX (blocking) for updating a ttl for a question in NX cache

Jump to

Keyboard shortcuts

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