Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedVariable ¶
type CachedVariable[T any] struct { // contains filtered or unexported fields }
CachedVariable is an atomic cached variable. It will store a value for the specified lifetime and allow retrieval of the value.
func NewCachedVariable ¶
func NewCachedVariable[T any](lifetime time.Duration) *CachedVariable[T]
NewCachedVariable creates a new cached variable with a given lifetime.
func (*CachedVariable[T]) Get ¶
func (c *CachedVariable[T]) Get() (T, bool)
Get returns the value if possible and a boolean indicating if the value was available.
func (*CachedVariable[T]) Reset ¶
func (c *CachedVariable[T]) Reset()
Reset resets the cached variable so that it no longer stores a value.
func (*CachedVariable[T]) Set ¶
func (c *CachedVariable[T]) Set(v T)
Set sets the value and resets the lifetime.
type Lazy ¶
type Lazy[T any] struct { Resolve func(context.Context) (T, error) // contains filtered or unexported fields }
Lazy persistently stores a value in memory by evaluating the Resolve function when the value is accessed
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func IgnoreCacheOption ¶
Click to show internal directories.
Click to hide internal directories.