Description
GET /api/v1/events hits the database on every request, causing latency spikes under load.
Goal
Cache the full events payload for 60 seconds using Redis (or an in‑memory LRU cache) and invalidate it on event creation/updation.
Tasks
- Add
redis (or dashmap) as a dependency in Cargo.toml.
- Create a
CacheLayer trait with get(key) / set(key, value, ttl) methods.
- In the handler for
GET /api/v1/events, check the cache first; if a miss, query the DB, store the result, and return it.
- In the event‑creation and event‑update handlers, purge the cache key (
"events:list").
- Add a unit test that verifies a cached response is returned on a second request.
Acceptance Criteria
/api/v1/events responds < 200 ms on subsequent calls (verified locally).
- Cache is cleared when a new event is added or an existing event is modified.
Dependencies
Depends on: None
Blocks: None
Description
GET /api/v1/eventshits the database on every request, causing latency spikes under load.Goal
Cache the full events payload for 60 seconds using Redis (or an in‑memory LRU cache) and invalidate it on event creation/updation.
Tasks
redis(ordashmap) as a dependency inCargo.toml.CacheLayertrait withget(key)/set(key, value, ttl)methods.GET /api/v1/events, check the cache first; if a miss, query the DB, store the result, and return it."events:list").Acceptance Criteria
/api/v1/eventsresponds < 200 ms on subsequent calls (verified locally).Dependencies
Depends on: None
Blocks: None