excache

package
v0.4.32 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFetchFnNotSet = fmt.Errorf("fetch function not set")

Functions

This section is empty.

Types

type CachedValue

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

func NewCachedValue

func NewCachedValue[T any](fetchInterval time.Duration, fetchFn ...func() (T, error)) *CachedValue[T]

func (*CachedValue[T]) Get

func (cv *CachedValue[T]) Get(fetchFn ...func() (T, error)) (T, error)

func (*CachedValue[T]) Refresh

func (cv *CachedValue[T]) Refresh(fetchFn ...func() (T, error)) (T, error)

func (*CachedValue[T]) Reset added in v0.4.29

func (cv *CachedValue[T]) Reset()

Reset cached value (will fetch next time)

func (*CachedValue[T]) SetFetchInterval

func (cv *CachedValue[T]) SetFetchInterval(fetchInterval time.Duration)

SetFetchInterval change fetch interval (will not affect nextFetch time)

func (*CachedValue[T]) SetNextFetchTime

func (cv *CachedValue[T]) SetNextFetchTime(t time.Time)

SetNextFetchTime change next fetch time

Jump to

Keyboard shortcuts

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