cache

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func DomainHash added in v0.3.1

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

DomainHash returns a hash for cache

func Hash

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

Hash returns a hash for cache

Types

type Cache added in v0.2.4

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

Cache is cache.

func New added in v0.2.4

func New(size int) *Cache

New returns a new cache.

func (*Cache) Add added in v0.2.4

func (c *Cache) Add(key uint64, el interface{})

Add adds a new element to the cache. If the element already exists it is overwritten.

func (*Cache) Get added in v0.2.4

func (c *Cache) Get(key uint64) (interface{}, bool)

Get looks up element index under key.

func (*Cache) Len added in v0.2.4

func (c *Cache) Len() int

Len returns the number of elements in the cache.

func (*Cache) Remove added in v0.2.4

func (c *Cache) Remove(key uint64)

Remove removes the element indexed with key.

Jump to

Keyboard shortcuts

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