cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.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 CachedEvaluator

type CachedEvaluator interface {
	GetCacheOnly() (value interface{})

	Get(ctx context.Context) (value interface{}, err error)

	// Evaluate is the same as Get, except:
	// Evaluate always ensures a Goroutine is evaluating. If there are no Goroutines evaluating then
	// evaluator is called.
	Evaluate(ctx context.Context) (value interface{}, err error)
}

CachedEvaluator is a cache for an evaluator (a function) such that the evaluator is expensive enough to justify ensuring that only one Goroutine should be running the evaluator at any one time (and other Goroutines will wait as needed). A CachedEvaluator should be wrapped for type-safety. See NewCachedEvaluator.

func NewCachedEvaluator

func NewCachedEvaluator(evaluator func(ctx context.Context) (value interface{}, err error)) (CachedEvaluator, error)

NewCachedEvaluator returns a cache for calls to evaluator, as defined by CachedEvaluator.

Jump to

Keyboard shortcuts

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