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.
Click to show internal directories.
Click to hide internal directories.