Files
lincodex/backend/internal/port/outbound/cache.go
T

23 lines
673 B
Go

package outbound
import (
"context"
"errors"
"time"
)
var (
ErrCacheMiss = errors.New("cache key not found")
ErrInvalidCacheKey = errors.New("cache key must not be empty")
ErrInvalidCacheTTL = errors.New("cache TTL must be positive")
)
// Cache stores serialized values with a mandatory expiration.
type Cache interface {
// Get returns ErrCacheMiss only when a key is absent, never on a service failure.
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
// Del succeeds when a key is already absent or no keys are supplied.
Del(ctx context.Context, keys ...string) error
}