cache

package
v5.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache holds a time-limited cache of values for string keys.

func New

func New(maxAge time.Duration) *Cache

New returns a new Cache that will cache items for at most maxAge.

func (*Cache) Evict

func (c *Cache) Evict(key string)

Evict removes the entry with the given key from the cache if present.

func (*Cache) EvictAll

func (c *Cache) EvictAll()

EvictAll removes all entries from the cache.

func (*Cache) Get

func (c *Cache) Get(key string, fetch func() (interface{}, error)) (interface{}, error)

Get returns the value for the given key, using fetch to fetch the value if it is not found in the cache. If fetch returns an error, the returned error from Get will have the same cause.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the total number of cached entries.

Jump to

Keyboard shortcuts

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