Skip to content

– BACKEND: Add server‑side cache for events list #943

Description

@OSEH-svg

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

  1. Add redis (or dashmap) as a dependency in Cargo.toml.
  2. Create a CacheLayer trait with get(key) / set(key, value, ttl) methods.
  3. In the handler for GET /api/v1/events, check the cache first; if a miss, query the DB, store the result, and return it.
  4. In the event‑creation and event‑update handlers, purge the cache key ("events:list").
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions