Documentation ¶
Index ¶
- Variables
- type Set
- func (c *Set[T]) Delete(key string) error
- func (c *Set[T]) Flush() error
- func (c *Set[T]) Get(key string, dest *T) error
- func (c *Set[T]) MutexGetSet(key string, dest *T, valueFunc func() (*T, error), expire time.Duration) (bool, error)
- func (c *Set[T]) Set(key string, value T, expire time.Duration)
- type Singular
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("cache entry not found")
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T any] struct { // contains filtered or unexported fields }
func (*Set[T]) MutexGetSet ¶
func (c *Set[T]) MutexGetSet(key string, dest *T, valueFunc func() (*T, error), expire time.Duration) (bool, error)
MutexGetSet gets value from cache and writes to dest, or if the key does not exist, it executes valueFunc to get cache value if the key still not exists when serially dispatched, sets value to cache and writes value to dest. The first return value means whether the value is got from cache or not. True means calculated; False means got from cache.
type Singular ¶
type Singular[T any] struct { // contains filtered or unexported fields }
func NewSingular ¶
func (*Singular[T]) MutexGetSet ¶
MutexGetSet gets value from cache and writes to dest, or if the key does not exist, it executes valueFunc to get cache value if the key still not exists when serially dispatched, sets value to cache and writes value to dest. The first return value means whether the value is got from cache or not. True means calculated; False means got from cache.