cache

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MPL-2.0 Imports: 2 Imported by: 1

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 is the internal cache implementation.

func New

func New() *Cache

New creates a cacher.

func (*Cache) Clear

func (c *Cache) Clear()

Clear empties the cache for all values.

func (*Cache) Expire

func (c *Cache) Expire(name string)

Expire removes the given item from the cache, if it exists.

func (*Cache) Fetch

func (c *Cache) Fetch(name string, t time.Duration, f Func) (interface{}, error)

Fetch retrieves an item from the cache. If the item exists in the cache and is within its lifetime, it is returned. If the item does not exist, or if the item exists but has exceeded its lifetime, the function f is invoked and the result is updated in the cache.

type Func

type Func func() (interface{}, error)

Func is the signature for a cache function.

Jump to

Keyboard shortcuts

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