feat(cache,worker): overhaul cache layer and add generation task lease recovery
Deployment Config CI / Deployment Config (push) Successful in 24s
Backend CI / Backend (push) Successful in 14m33s

- 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>
This commit is contained in:
2026-05-03 02:02:39 +08:00
parent bbfeabdaa5
commit c1ef717d17
37 changed files with 2502 additions and 93 deletions
+12 -1
View File
@@ -126,7 +126,18 @@ func New(configPath string) (*App, error) {
cfg.RabbitMQ.DesktopDispatchMonitorPrefix + ".*.*",
}
desktopDispatch := stream.NewDesktopDispatchHub(mqClient, logger, desktopDispatchBindings)
appCache := cache.New(cfg.Cache.Driver, rdb)
appCache := cache.NewWithOptions(cfg.Cache.Driver, rdb, cache.Options{
Namespace: cfg.Cache.Namespace,
JitterRatio: cfg.Cache.JitterRatio,
MetricsEnabled: cfg.Cache.MetricsEnabled,
AsyncFillEnabled: cfg.Cache.AsyncFillEnabled,
AsyncFillWorkers: cfg.Cache.AsyncFillWorkers,
AsyncFillBuffer: cfg.Cache.AsyncFillBuffer,
AsyncFillTimeout: cfg.Cache.AsyncFillTimeout,
L1Enabled: cfg.Cache.L1Enabled,
L1TTL: cfg.Cache.L1TTL,
DeleteScanCount: cfg.Cache.DeleteScanCount,
})
brandService := tenantapp.NewBrandService(pool, monitoringPool, auditLogs, cfg.BrandLibrary).WithCache(appCache)
monitoringService := tenantapp.NewMonitoringService(pool, monitoringPool, mqClient, cfg.MonitoringDispatch, cfg.BrandLibrary, logger).WithRedis(rdb)
kolProfiles := repository.NewKolProfileRepository(pool)