Version: v1.2.1 Latest Latest

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 6 Imported by: 0




This section is empty.


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


func AcquireBuf added in v1.0.0

func AcquireBuf() *bytes.Buffer

AcquireBuf returns a buf from pool

func AcquireHash added in v1.0.0

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 added in v1.0.0

func ReleaseBuf(buf *bytes.Buffer)

ReleaseBuf returns buf to pool

func ReleaseHash added in v1.0.0

func ReleaseHash(h hash.Hash64)

ReleaseHash returns hash to pool


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