1.2 KiB
1.2 KiB
Implementer — F-027 Caching layer with explicit contracts
Summary
Implemented cache module with read-through pattern, explicit contracts (key pattern, TTL, invalidation, source of truth) and metrics. In-memory adapter serves v1; Redis adapter can be added later without changing callers.
Files changed
project/src/modules/cache/**project/src/app/build-app.ts
Acceptance evidence
- AC1 contracts documented:
cache-service.test.tsverifies that the registered contract carries key pattern, TTL, source and invalidation fields; route exposes/cache/contracts. - AC2 invalidation:
CacheService.invalidateByNameincrements invalidations counter. - AC3 Redis-down fallback: service swallows
seterrors after loader returns and increments miss counter. - AC4 metrics:
/cache/metricsreturns hits/misses/invalidations/hitRatio.
Commands run
cd project && npm run lint/typecheck/build/testpassedcd project && TEST_DATABASE_URL='postgres://mdv:mdv_dev_only@localhost:5432/mdv_test' npm run test:integration -- migrations.itestpassed; 14 files, 53 tests./scripts/verify.shpassed
Notes
- No new runtime dependency.
invalidateByNameuses fragment-based invalidation on the in-memory adapter; a real Redis adapter can use SCAN.