cache

package
v0.0.0-...-b3e95c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("key not found")
)

Functions

This section is empty.

Types

type Cache

type Cache[T any] interface {
	Set(ctx context.Context, key string, value T) error
	SetWithTTL(ctx context.Context, key string, value T, ttl time.Duration) error
	Delete(ctx context.Context, key string) error
	Get(ctx context.Context, key string) (T, error)
	GetAll(ctx context.Context, selectFunc Matcher) (map[string]T, error)
	UpdateTTL(ctx context.Context, key string, ttl time.Duration) error
}

Cache is an interface for a cache that can be used to store and retrieve values.

func New

func New[T any]() Cache[T]

New creates a new cache.

type Matcher

type Matcher func(key string) bool

Matcher is a function that returns true if the key matches.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL