Versions in this module Expand all Collapse all v0 v0.48.3 Mar 12, 2024 v0.48.2 Mar 11, 2024 v0.48.1 Mar 8, 2024 v0.48.0 Mar 8, 2024 Changes in this version + var LogConfig = struct{ ... } + func NewContext[K comparable, V any](ctx context.Context, c *Cache[K, V]) context.Context + type Cache struct + func FromContext[K comparable, V any](ctx context.Context) *Cache[K, V] + func New[K comparable, V any](fetch FetchFunc[K, V], opts ...Opt) *Cache[K, V] + func (c *Cache[K, V]) Clear(ctx context.Context) + func (c *Cache[K, V]) Close() error + func (c *Cache[K, V]) Delete(ctx context.Context, key K) + func (c *Cache[K, V]) Get(ctx context.Context, key K) (V, error) + func (c *Cache[K, V]) Has(key K) bool + func (c *Cache[K, V]) Keys() []K + func (c *Cache[K, V]) Len() int + func (c *Cache[K, V]) LogValue() slog.Value + func (c *Cache[K, V]) MaybeSet(ctx context.Context, key K, val V, err error) (ok bool) + func (c *Cache[K, V]) Name() string + func (c *Cache[K, V]) String() string + type Entry struct + Cache *Cache[K, V] + Err error + Key K + Val V + func (e Entry[K, V]) LogValue() slog.Value + func (e Entry[K, V]) String() string + type Event struct + Op Op + func (e Event[K, V]) LogValue() slog.Value + func (e Event[K, V]) String() string + type FetchFunc func(ctx context.Context, key K) (val V, err error) + type Name string + type Op uint8 + const OpEvict + const OpFill + const OpHit + const OpMiss + func (o Op) IsZero() bool + func (o Op) String() string + type Opt interface + func Log(log *slog.Logger, lvl slog.Leveler, ops ...Op) Opt + func OnEvent[K comparable, V any](ch chan<- Event[K, V], block bool, ops ...Op) Opt + func OnEvict[K comparable, V any](fn func(ctx context.Context, key K, val V, err error)) Opt + func OnFill[K comparable, V any](fn func(ctx context.Context, key K, val V, err error)) Opt + func OnHit[K comparable, V any](fn func(ctx context.Context, key K, val V, err error)) Opt + func OnMiss[K comparable, V any](fn func(ctx context.Context, key K)) Opt