cache

package
v0.0.0-...-703489d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 0 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 interface {
	// Compute will compute value only once using provider and save it in cache,
	// so subsequent calls will return value directly from cache. In case of
	// provider returning error, this error will be returned, but not saved in
	// cache.
	Compute(key interface{}, provider func() (interface{}, error)) (interface{}, error)
	// Drop will drop value from cache only if given key is found. Otherwise, it
	// will return nil.
	Drop(key interface{}) interface{}
}

Cache allows computing values only once.

type NoopCache

type NoopCache struct{}

NoopCache do not do any caching. Probably, should be only used for testing purposes.

func (NoopCache) Compute

func (n NoopCache) Compute(_ interface{}, provider func() (interface{}, error)) (interface{}, error)

func (NoopCache) Drop

func (n NoopCache) Drop(_ interface{}) interface{}

Jump to

Keyboard shortcuts

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