Versions in this module Expand all Collapse all v1 v1.1.1 Mar 29, 2024 v1.0.1 May 5, 2022 Changes in this version + var ErrNotFound = errors.New("key not found in cache") + type Cache struct + func NewCache[K Key, V Value](params CacheParams[K, V]) *Cache[K, V] + func (tc *Cache[K, V]) Close() error + func (tc *Cache[K, V]) Get(ctx context.Context, key K) (V, error) + func (tc *Cache[K, V]) GetIfPresent(ctx context.Context, key K) (V, bool) + func (tc *Cache[K, V]) Invalidate(ctx context.Context, key K) + func (tc *Cache[K, V]) InvalidateAll(ctx context.Context) + func (tc *Cache[K, V]) Put(ctx context.Context, key K, val V) + func (tc *Cache[K, V]) Refresh(ctx context.Context, key K) error + func (tc *Cache[K, V]) SetLoader(lf LoaderFunc[K, V]) + type CacheParams struct + Expires time.Duration + Loader LoaderFunc[K, V] + Size int + Type CacheType + type CacheType int + const LFU + const LRU + type Func func(K, V) + type Key comparable + type LoaderFunc func(context.Context, K) (V, error) + type LoadingCache interface + Get func(context.Context, K) (V, error) + Refresh func(context.Context, K) error + SetLoader func(LoaderFunc[K, V]) + type SomeCache interface + Close func() error + GetIfPresent func(context.Context, K) (V, bool) + Invalidate func(context.Context, K) + InvalidateAll func(context.Context) + Put func(context.Context, K, V) + type Value any