Context
A request row is read frequently (dashboard polls, webhook consumers) but changes rarely. Hitting Postgres every time is wasteful.
Acceptance criteria
- Cache the serialized request under
req:<contract>:<id> with a configurable TTL (env CACHE_TTL, default 15s).
- Invalidate the cache on write from the indexer (paid/cancelled).
- Falls back to DB on cache miss / Redis error; never hard-fail.
Technical notes
- Use the existing
ioredis client.
- Keep TTL short; state changes must reflect quickly.
Testing
- Test that a cache hit returns DB data and a subsequent invalidation forces a refresh.
Context
A request row is read frequently (dashboard polls, webhook consumers) but changes rarely. Hitting Postgres every time is wasteful.
Acceptance criteria
req:<contract>:<id>with a configurable TTL (envCACHE_TTL, default 15s).Technical notes
ioredisclient.Testing