cache

package
Version: v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WallClock is the wall clock
	WallClock = clockwork.NewRealClock()

	// ErrCacheNotFound error
	ErrCacheNotFound = errors.New("cache not found")
	// ErrCacheExpired error
	ErrCacheExpired = errors.New("cache expired")
)

Functions

func Hash

func Hash(q dns.Question, cd ...bool) uint64

Hash returns a hash for cache

Types

type AuthServer

type AuthServer struct {
	Host  string
	Rtt   int64
	Count int64
}

AuthServer type

func NewAuthServer

func NewAuthServer(host string) *AuthServer

NewAuthServer return a server

func (*AuthServer) String

func (a *AuthServer) String() string

type AuthServers

type AuthServers struct {
	sync.RWMutex

	List []*AuthServer
	// contains filtered or unexported fields
}

AuthServers type

func (*AuthServers) TrySort

func (s *AuthServers) TrySort()

TrySort if necessary sort servers by rtt

type BlockCache

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

BlockCache type

func NewBlockCache

func NewBlockCache() *BlockCache

NewBlockCache returns a new blockcache

func (*BlockCache) Exists

func (c *BlockCache) Exists(key string) bool

Exists returns whether or not a key exists in the cache

func (*BlockCache) Get

func (c *BlockCache) Get(key string) (bool, error)

Get returns the entry for a key or an error

func (*BlockCache) Length

func (c *BlockCache) Length() int

Length returns the caches length

func (*BlockCache) Remove

func (c *BlockCache) Remove(key string)

Remove removes an entry from the cache

func (*BlockCache) Set

func (c *BlockCache) Set(key string)

Set sets a value in the BlockCache

type ErrorCache

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

ErrorCache type

func NewErrorCache

func NewErrorCache(size int, ttl uint32) *ErrorCache

NewErrorCache return new cache

func (*ErrorCache) Get

func (c *ErrorCache) Get(key uint64) error

Get returns the entry for a key or an error

func (*ErrorCache) Len

func (c *ErrorCache) Len() int

Len returns the caches length

func (*ErrorCache) Remove

func (c *ErrorCache) Remove(key uint64)

Remove removes an entry from the cache

func (*ErrorCache) Set

func (c *ErrorCache) Set(key uint64) error

Set sets a keys value to a error cache

type LQueue

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

LQueue type

func NewLookupQueue

func NewLookupQueue() *LQueue

NewLookupQueue func

func (*LQueue) Add

func (q *LQueue) Add(key uint64)

Add func

func (*LQueue) Done

func (q *LQueue) Done(key uint64)

Done func

func (*LQueue) Get

func (q *LQueue) Get(key uint64) <-chan struct{}

Get func

func (*LQueue) Wait

func (q *LQueue) Wait(key uint64)

Wait func

type NS

type NS struct {
	Servers    *AuthServers
	Network    string
	DSRR       []dns.RR
	TTL        uint32
	UpdateTime time.Time
	// contains filtered or unexported fields
}

NS represents a cache entry

type NSCache

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

NSCache type

func NewNSCache

func NewNSCache() *NSCache

NewNSCache return new cache

func (*NSCache) Exists

func (c *NSCache) Exists(key uint64) bool

Exists returns whether or not a key exists in the cache

func (*NSCache) Full

func (c *NSCache) Full() bool

Full returns whether or not the cache is full

func (*NSCache) Get

func (c *NSCache) Get(key uint64) (*NS, error)

Get returns the entry for a key or an error

func (*NSCache) Length

func (c *NSCache) Length() int

Length returns the caches length

func (*NSCache) Remove

func (c *NSCache) Remove(key uint64)

Remove removes an entry from the cache

func (*NSCache) Set

func (c *NSCache) Set(key uint64, dsRR []dns.RR, ttl uint32, servers *AuthServers)

Set sets a keys value to a NS

type Query

type Query struct {
	Item       *item
	RateLimit  *rl.RateLimiter
	UpdateTime time.Time
	// contains filtered or unexported fields
}

Query represents a cache entry

type QueryCache

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

QueryCache type

func NewQueryCache

func NewQueryCache(size int, ratelimit int) *QueryCache

NewQueryCache return new cache

func (*QueryCache) Get

func (c *QueryCache) Get(key uint64, req *dns.Msg) (*dns.Msg, *rl.RateLimiter, error)

Get returns the entry for a key or an error

func (*QueryCache) Len

func (c *QueryCache) Len() int

Len returns the caches length

func (*QueryCache) Remove

func (c *QueryCache) Remove(key uint64)

Remove removes an entry from the cache

func (*QueryCache) Set

func (c *QueryCache) Set(key uint64, msg *dns.Msg) error

Set sets a keys value to a Mesg

Jump to

Keyboard shortcuts

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