cache

package
v0.0.0-...-cc94f9d Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 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 Hash

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

Hash returns a hash for cache

Types

type Cache

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

Cache is cache.

func New

func New(size int) *Cache

New returns a new cache.

func (*Cache) Add

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

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

Get looks up element index under key.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of elements in the cache.

func (*Cache) Remove

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