Versions in this module Expand all Collapse all v0 v0.1.0 Aug 15, 2026 Changes in this version + var ErrClosed = errors.New("cache: closed") + var ErrEmptyKey = errors.New("cache: key must not be empty") + var ErrInvalidCapacity = errors.New("cache: capacity must be greater than zero") + var ErrNotFound = errors.New("cache: key not found") + func GetJSON(ctx context.Context, c ByteCache, key string, dest any) error + func GetOrSet(ctx context.Context, c ByteCache, key string, ttl time.Duration, ...) ([]byte, error) + func GetString(ctx context.Context, c ByteCache, key string) (string, error) + func SetJSON(ctx context.Context, c ByteCache, key string, value any, ttl time.Duration) error + func SetString(ctx context.Context, c ByteCache, key, value string, ttl time.Duration) error + type ByteCache = Cache[string, []byte] + type Cache interface + Clear func(ctx context.Context) error + Close func() error + Delete func(ctx context.Context, key K) error + Exists func(ctx context.Context, key K) (bool, error) + Get func(ctx context.Context, key K) (V, error) + Set func(ctx context.Context, key K, value V, ttl time.Duration) error + type Getter interface + Exists func(ctx context.Context, key K) (bool, error) + Get func(ctx context.Context, key K) (V, error) + type Option func(*Options) + func WithDefaultTTL(ttl time.Duration) Option + func WithPrefix(prefix string) Option + type Options struct + DefaultTTL time.Duration + Prefix string + func ApplyOptions(opts ...Option) Options + func (o Options) Key(key string) string + func (o Options) ResolveTTL(ttl time.Duration) time.Duration + type Setter interface + Delete func(ctx context.Context, key K) error + Set func(ctx context.Context, key K, value V, ttl time.Duration) error