Description
Once GET /api/apis reads from the database it will be a hot, mostly-read endpoint for the marketplace. This backend task adds a short-TTL cache layer with explicit invalidation on API create/update so listing reads stay fast without serving stale catalogs.
Requirements and Context
- Add a cache abstraction with TTL keyed by listing query params.
- Invalidate on writes through
src/repositories/apiRepository.ts.
- Emit cache hit/miss counters via
src/metrics.ts.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feature/apis-listing-cache
- Implement changes
- New cache helper under
src/lib/
src/routes/apis.ts — cache lookups
src/metrics.ts — add hit/miss counters
- Test and commit
npm test -- src/__tests__/metricsLatency.test.ts
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: cache GET /api/apis listings with TTL invalidation
Acceptance Criteria
Guidelines
- Minimum 90% test coverage with Jest
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
Once
GET /api/apisreads from the database it will be a hot, mostly-read endpoint for the marketplace. This backend task adds a short-TTL cache layer with explicit invalidation on API create/update so listing reads stay fast without serving stale catalogs.Requirements and Context
src/repositories/apiRepository.ts.src/metrics.ts.Suggested Execution
src/lib/src/routes/apis.ts— cache lookupssrc/metrics.ts— add hit/miss countersnpm test -- src/__tests__/metricsLatency.test.tsExample commit message
Acceptance Criteria
Guidelines