factscache

package
v0.0.0-...-ba26d65 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrUpdate

func GetOrUpdate(
	cache *FactsCache,
	entry string,
	udpateFunc UpdateCacheFunc,
	updateFuncArgs ...interface{},
) (interface{}, error)

GetOrUpdate Runs FactsCache GetOrUpdate with a provided cache If the cache is nil, it runs the function, otherwise it returns from cache

Types

type Entry

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

type FactsCache

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

func NewFactsCache

func NewFactsCache() *FactsCache

func (*FactsCache) Entries

func (c *FactsCache) Entries() []string

Entries returns the cached entries list

func (*FactsCache) GetOrUpdate

func (c *FactsCache) GetOrUpdate(
	entry string,
	udpateFunc UpdateCacheFunc,
	updateFuncArgs ...interface{},
) (interface{}, error)

GetOrUpdate returns the cached result providing an entry name or runs the updateFunc to generate the entry. It locks its usage for each used key, returning the same value of the first execution in the additional usages. If other function with a different key is asked, it runs in parallel without blocking.

type UpdateCacheFunc

type UpdateCacheFunc func(args ...interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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