c1ef717d17
- shared/cache: add Options/L1/async/metrics/prefix decorators, multi-key ops, Redis pool tuning, and JSON readthrough metrics - worker-generate: claim tasks via DB lease + heartbeat, requeue stale queued tasks, expire dead leases with refund/cache invalidation - tenant: version article cache keys so worker recovery invalidations propagate cleanly - shared/config: expand Redis (pool/timeouts/TLS) and Generation (lease/recovery) configs with defaults Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
618 B
Go
26 lines
618 B
Go
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
|
|
}
|