cache

package
v0.0.0-...-aa25bfb Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimedMemoize

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

TimedMemoize wraps a function returning (value, error) and caches the value AND the error for a specific time. This cache is mainly used to ensure external calls rates are reasonable. The cache is thread-safe.

func NewTimedMemoize

func NewTimedMemoize[T any](getter func(ctx context.Context) (T, error), duration time.Duration) *TimedMemoize[T]

NewTimedMemoize builds and returns a TimedMemoize

func (*TimedMemoize[T]) Get

func (c *TimedMemoize[T]) Get(ctx context.Context) (T, error)

Get does a cache lookup and updates the cache in case of cache miss.

Jump to

Keyboard shortcuts

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