Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memoizer ¶
type Memoizer[T any] struct { // The function to call to get the value. Function func() (*T, error) // The time after which the value should be invalidated. InvalidateAfter time.Duration // The time at which the value was last loaded. LastLoaded time.Time // The mutex to use for locking. Mutex sync.RWMutex // The value of the memoizer. Value *T }
Memoizer can cache a value for a certain amount of time. Used for caching a function return value.
func (*Memoizer[T]) Get ¶
Get gets the value of the memoizer. If the value is not cached, it will call the function to get the value.
func (*Memoizer[T]) GetCacheValue ¶
func (m *Memoizer[T]) GetCacheValue() *T
GetCacheValue gets the current cached value.
func (*Memoizer[T]) InvalidateTime ¶
InvalidateTime returns the time after which the value should be invalidated.
Click to show internal directories.
Click to hide internal directories.