Files

26 lines
618 B
Go
Raw Permalink Normal View History

package cache
import (
"context"
"errors"
"time"
)
var ErrNotFound = errors.New("cache: key not found")
type Item struct {
Key string
Value []byte
TTL time.Duration
}
type Cache interface {
Get(ctx context.Context, key string) ([]byte, error)
GetMulti(ctx context.Context, keys []string) (map[string][]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
SetMulti(ctx context.Context, items []Item) error
Delete(ctx context.Context, key string) error
DeleteMany(ctx context.Context, keys []string) error
DeletePrefix(ctx context.Context, prefix string) error
}