Documentation ¶
Index ¶
- Variables
- type CachedValue
- func (cv *CachedValue[T]) Get(fetchFn ...func() (T, error)) (T, error)
- func (cv *CachedValue[T]) Refresh(fetchFn ...func() (T, error)) (T, error)
- func (cv *CachedValue[T]) Reset()
- func (cv *CachedValue[T]) SetFetchInterval(fetchInterval time.Duration)
- func (cv *CachedValue[T]) SetNextFetchTime(t time.Time)
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
Click to show internal directories.
Click to hide internal directories.