Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fetcher ¶ added in v1.52.1
type Fetcher[K comparable, V any] func(context.Context, K) (V, error)
Fetcher is a function which can fetch an item which doesn't yet exist in the cache.
type Local ¶ added in v1.52.1
type Local[K comparable, V any] struct { // contains filtered or unexported fields }
Local is a generic in-memory cache with builtin in fetching of missing items.
func (*Local[K, V]) Clear ¶ added in v1.52.2
func (c *Local[K, V]) Clear()
Clear removes all items from the cache.
func (*Local[K, V]) Get ¶ added in v1.52.1
func (c *Local[K, V]) Get(key K) V
Get returns the item with the given key from the cache or the type's zero value.
func (*Local[K, V]) GetOrFetch ¶ added in v1.52.2
GetOrFetch looks for the item in cache and if not found tries to fetch it.
func (*Local[K, V]) Set ¶ added in v1.52.2
func (c *Local[K, V]) Set(key K, val V)
Set overwrites the value for the given key.
Click to show internal directories.
Click to hide internal directories.