cache

package
v0.20.18 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 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 GenericCache

type GenericCache[T any] struct {
	// contains filtered or unexported fields
}

GenericCache holds a value of type T, fetched once at startup and then refreshed on a fixed interval. Any caller to Get will see the most recent successful fetch.

func NewGenericCache

func NewGenericCache[T any](
	fetchFn func(ctx *armadacontext.Context) (T, error),
	updateFrequency time.Duration,
) *GenericCache[T]

NewGenericCache returns a cache that will call fetchFn initially (via Initialise) and then every updateFrequency in its Run loop.

func (*GenericCache[T]) Get

func (c *GenericCache[T]) Get(_ *armadacontext.Context) (T, error)

Get returns the last‐stored value, or an error if we never successfully fetched it yet.

func (*GenericCache[T]) Initialise

func (c *GenericCache[T]) Initialise(ctx *armadacontext.Context) error

Initialise does one immediate fetch (so Get never errors once Run starts).

func (*GenericCache[T]) Run

func (c *GenericCache[T]) Run(ctx *armadacontext.Context) error

Run will keep refreshing in the background until ctx is Done.

Jump to

Keyboard shortcuts

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