Documentation ¶
Index ¶
- type MemoizeCache
- func (c *MemoizeCache[K, V]) Memoize(key K, f func() V) V
- func (c *MemoizeCache[K, V]) MemoizeCanErr(key K, f func() (V, error)) (V, error)
- func (c *MemoizeCache[K, V]) MemoizeCanErrWithTTL(key K, ttl time.Duration, errorTTL time.Duration, f func() (V, error)) (V, error)
- func (c *MemoizeCache[K, V]) MemoizeWithTTL(key K, ttl time.Duration, f func() V) V
- type RWMutexCache
- type RWMutexTTLCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoizeCache ¶
type MemoizeCache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewMemoizeCache ¶
func NewMemoizeCache[K comparable, V any](defaultTTL time.Duration, errorTTL time.Duration) *MemoizeCache[K, V]
func (*MemoizeCache[K, V]) Memoize ¶
func (c *MemoizeCache[K, V]) Memoize(key K, f func() V) V
func (*MemoizeCache[K, V]) MemoizeCanErr ¶
func (c *MemoizeCache[K, V]) MemoizeCanErr(key K, f func() (V, error)) (V, error)
func (*MemoizeCache[K, V]) MemoizeCanErrWithTTL ¶
func (*MemoizeCache[K, V]) MemoizeWithTTL ¶
func (c *MemoizeCache[K, V]) MemoizeWithTTL(key K, ttl time.Duration, f func() V) V
type RWMutexCache ¶
type RWMutexCache[K comparable, V any] struct { // contains filtered or unexported fields }
func NewRWMutexCache ¶
func NewRWMutexCache[K comparable, V any]() *RWMutexCache[K, V]
func (*RWMutexCache[K, V]) Delete ¶
func (c *RWMutexCache[K, V]) Delete(key K) (V, bool)
func (*RWMutexCache[K, V]) Get ¶
func (c *RWMutexCache[K, V]) Get(key K) (V, bool)
func (*RWMutexCache[K, V]) Put ¶
func (c *RWMutexCache[K, V]) Put(key K, value V) (V, bool)
type RWMutexTTLCache ¶
type RWMutexTTLCache[K comparable, V any] struct { DefaultTTL time.Duration // contains filtered or unexported fields }
func NewRWMutexTTLCache ¶
func NewRWMutexTTLCache[K comparable, V any](defaultTTL time.Duration) *RWMutexTTLCache[K, V]
func (*RWMutexTTLCache[K, V]) Delete ¶
func (c *RWMutexTTLCache[K, V]) Delete(key K) (V, bool)
func (*RWMutexTTLCache[K, V]) Get ¶
func (c *RWMutexTTLCache[K, V]) Get(key K) (V, bool)
func (*RWMutexTTLCache[K, V]) Put ¶
func (c *RWMutexTTLCache[K, V]) Put(key K, value V) (V, bool)
func (*RWMutexTTLCache[K, V]) PutWithTTL ¶
func (c *RWMutexTTLCache[K, V]) PutWithTTL(key K, value V, ttl time.Duration) (V, bool)
Click to show internal directories.
Click to hide internal directories.