sdns: github.com/semihalev/sdns/cache Index | Files

package cache

import "github.com/semihalev/sdns/cache"

Index

Package Files

cache.go hash.go shard.go

Variables

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

func AcquireBuf Uses

func AcquireBuf() *bytes.Buffer

AcquireBuf returns a buf from pool

func AcquireHash Uses

func AcquireHash() hash.Hash64

AcquireHash returns a hash from pool

func Hash Uses

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

Hash returns a hash for cache

func ReleaseBuf Uses

func ReleaseBuf(buf *bytes.Buffer)

ReleaseBuf returns buf to pool

func ReleaseHash Uses

func ReleaseHash(h hash.Hash64)

ReleaseHash returns hash to pool

type Cache Uses

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

Cache is cache.

func New Uses

func New(size int) *Cache

New returns a new cache.

func (*Cache) Add Uses

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 Uses

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

Get looks up element index under key.

func (*Cache) Len Uses

func (c *Cache) Len() int

Len returns the number of elements in the cache.

func (*Cache) Remove Uses

func (c *Cache) Remove(key uint64)

Remove removes the element indexed with key.

Package cache imports 6 packages (graph) and is imported by 4 packages. Updated 2020-08-10. Refresh now. Tools for package owners.