cycle

package
v0.0.0-...-de93505 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 3 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[T any] struct {
	// contains filtered or unexported fields
}

Cache is a thread-safe generic struct that you can use to cache values for the current cycle. On a new cycle, determined by cycle metadata, the callback function is called and a new value is initialized. If the callback fails and an old value exists, it is re-used.

func NewCache

func NewCache[T any](log *logp.Logger) *Cache[T]

func (*Cache[T]) GetValue

func (c *Cache[T]) GetValue(ctx context.Context, cycle Metadata, fetch func(context.Context) (T, error)) (T, error)

type Metadata

type Metadata struct {
	Sequence int64
}

Jump to

Keyboard shortcuts

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