cache

package
v0.0.0-...-19bb427 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Round

func Round(val float64) uint32

Types

type Cache

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

Cache is a thread-safe fixed size LRU cache.

func New

func New(size int) (*Cache, error)

New creates an LRU of the given size

func NewWithEvict

func NewWithEvict(size int, onEvicted func(s *utils.Entry)) (*Cache, error)

NewWithEvict constructs a fixed size cache with the given eviction callback.

func (*Cache) Add

func (c *Cache) Add(s utils.Service) bool

Add adds a value to the cache. Returns true if an eviction occurred.

func (*Cache) Containkey

func (c *Cache) Containkey(name string) bool

Contains judge whether domain is in the cache

func (*Cache) Contains

func (c *Cache) Contains(name string, rt string) bool

func (*Cache) Get

func (c *Cache) Get(s utils.Service) ([]utils.Entry, error)

Get looks up a key's value from the cache.

func (*Cache) Keys

func (c *Cache) Keys() []interface{}

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) List

func (c *Cache) List() []utils.Service

List return all items in the cache.

func (*Cache) Purge

func (c *Cache) Purge()

Purge is used to completely clear the cache

func (*Cache) Remove

func (c *Cache) Remove(s utils.Service) error

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

func (*Cache) Set

func (c *Cache) Set(originalValue utils.Service, modifyValue utils.Service) error

Set sets the provided key from the cache.

type MsgCache

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

Cache is a thread-safe fixed size LRU cache.

func NewMsgCache

func NewMsgCache(size int) (*MsgCache, error)

New creates an LRU of the given size

func NewMsgCacheWithEvict

func NewMsgCacheWithEvict(size int, onEvicted func(s *[]dns.RR)) (c *MsgCache, err error)

NewWithEvict constructs a fixed size cache with the given eviction callback.

func (*MsgCache) Add

func (c *MsgCache) Add(s []dns.RR, rtype uint16) bool

Add adds a value to the cache. Returns true if an eviction occurred.

func (*MsgCache) Get

func (c *MsgCache) Get(name string, rtype uint16) ([]dns.RR, *time.Time, error)

Get looks up a key's value from the cache.

func (*MsgCache) Keys

func (c *MsgCache) Keys() (result []interface{})

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*MsgCache) Len

func (c *MsgCache) Len() (result int)

Len returns the number of items in the cache.

func (*MsgCache) Purge

func (c *MsgCache) Purge()

Purge is used to completely clear the cache

func (*MsgCache) Remove

func (c *MsgCache) Remove(name string, rtype uint16) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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