Skip to content

Add response caching with TTL for GET /api/apis marketplace listings #314

@greatest0fallt1me

Description

@greatest0fallt1me

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

  1. Fork the repo and create a branch
    git checkout -b feature/apis-listing-cache
  2. Implement changes
    • New cache helper under src/lib/
    • src/routes/apis.ts — cache lookups
    • src/metrics.ts — add hit/miss counters
  3. 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

  • Repeated listing reads within TTL hit the cache
  • API create/update invalidates affected cache keys
  • Cache hit/miss metrics are exported

Guidelines

  • Minimum 90% test coverage with Jest
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programapiAPI endpoint/contract workbackendBackend service workperformancePerformance/efficiency
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions