cache

package
Version: v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 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 AcquireBuf

func AcquireBuf() *bytes.Buffer

AcquireBuf returns a buf from pool

func AcquireHash

func AcquireHash() hash.Hash64

AcquireHash returns a hash from pool

func Hash

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

Hash returns a hash for cache

func ReleaseBuf

func ReleaseBuf(buf *bytes.Buffer)

ReleaseBuf returns buf to pool

func ReleaseHash

func ReleaseHash(h hash.Hash64)

ReleaseHash returns hash to pool

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
t or T : Toggle theme light dark auto