Overview
src/caching/cache-warming.service.ts issues five repository reads (lines 55, 85, 92, 132, 139) against the courses and users tables with no take. Cache warming runs on a schedule and on startup, so at each invocation the service loads a full table into memory in order to populate the cache with entries that, by definition, have a bounded useful size. On a large dataset a warming pass can consume more memory than the cache it is filling, and because it runs at startup it competes with the application's own initialisation for both memory and database connections.
Specifications
Features:
- Warming reads a bounded, prioritised working set.
- Warming is throttled so it does not compete with live traffic.
Tasks:
- Add an explicit
take to each read, sized from a configurable CACHE_WARM_MAX_ENTRIES.
- Prioritise the warmed set by a real signal — enrollment count for courses, recent activity for users — rather than reading everything.
- Process the working set in batches with a small delay between them to bound database and memory pressure.
- Emit metrics for entries warmed and warming duration.
- Defer startup warming until after the server is accepting traffic.
Impacted Files:
src/caching/cache-warming.service.ts
src/caching/cache-warming.scheduler.ts
Acceptance Criteria
- No warming query reads an unbounded result set.
- The warmed set is selected by a documented priority signal.
- Warming duration and entry count are exported as metrics.
- Startup warming does not delay readiness.
Overview
src/caching/cache-warming.service.tsissues five repository reads (lines 55, 85, 92, 132, 139) against the courses and users tables with notake. Cache warming runs on a schedule and on startup, so at each invocation the service loads a full table into memory in order to populate the cache with entries that, by definition, have a bounded useful size. On a large dataset a warming pass can consume more memory than the cache it is filling, and because it runs at startup it competes with the application's own initialisation for both memory and database connections.Specifications
Features:
Tasks:
taketo each read, sized from a configurableCACHE_WARM_MAX_ENTRIES.Impacted Files:
src/caching/cache-warming.service.tssrc/caching/cache-warming.scheduler.tsAcceptance Criteria