Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimeDefinedCache ¶
type TimeDefinedCache[T any] struct { // contains filtered or unexported fields }
func NewTimeDefinedCache ¶
func NewTimeDefinedCache[T any](minRefreshDuration time.Duration, useValueLock bool, reCalcFunc func() (T, error)) (*TimeDefinedCache[T], error)
NewTimeDefinedCache creates a new cache that will refresh the value every minRefreshDuration. If the value is requested before the minRefreshDuration has passed, the cached value will be returned. If minRefreshDuration is zero, the value will always be recalculated. In addition, a Set() can be used to explicitly set the value. If useValueLock is set to true, the value will be locked when being set. If the cache won't be used concurrently, it's safe to set this to false.
func (*TimeDefinedCache[T]) Get ¶
func (t *TimeDefinedCache[T]) Get() (T, error)
func (*TimeDefinedCache[T]) Set ¶
func (t *TimeDefinedCache[T]) Set(value T)
Click to show internal directories.
Click to hide internal directories.