cache

package
v0.0.0-...-3dd6856 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AgentCachePrefix is the common root to use to prefix all the cache
	// keys for any value regarding the Agent
	AgentCachePrefix = "agent"

	// NoExpiration maps to go-cache corresponding value
	NoExpiration = cache.NoExpiration
)

Variables

View Source
var Cache = cache.New(defaultExpire, defaultPurge)

Cache provides an in-memory key:value store similar to memcached

Functions

func BuildAgentKey

func BuildAgentKey(keys ...string) string

BuildAgentKey creates a cache key by joining the constant AgentCachePrefix and path elements passed as arguments. It is to be used by core agent packages to reuse the prefix constant

Types

type BasicCache

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

BasicCache is a simple threadsafe cache

func NewBasicCache

func NewBasicCache() *BasicCache

NewBasicCache Creates new BasicCache

func (*BasicCache) Add

func (b *BasicCache) Add(k string, v interface{})

Add adds value to cache for specified key

func (*BasicCache) Get

func (b *BasicCache) Get(k string) (interface{}, error)

Get gets interface for specified key or error

func (*BasicCache) GetModified

func (b *BasicCache) GetModified() int64

GetModified gets interface for specified key or error

func (*BasicCache) Items

func (b *BasicCache) Items() map[string]interface{}

Items returns a map with the elements in the cache

func (*BasicCache) Remove

func (b *BasicCache) Remove(k string)

Remove removes an entry from the cache if it exists

func (*BasicCache) Size

func (b *BasicCache) Size() int

Size returns the current size of the cache

Jump to

Keyboard shortcuts

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