Skip to content

Redis

Redis is used exclusively for leaderboard result caching. It is not used for sessions, auth tokens, or any other data.


Connection

ConnectionStrings__Redis=localhost:6379

Production: Redis add-on on Railway.


Cache Keys

Key pattern Value TTL Invalidated by
lb:{trackId}:{vehicleFilter}:{page}:{pageSize} JSON leaderboard entry list 5 minutes New leaderboard submission for that track

Behaviour

  • On GET /v1/leaderboards: check cache → return if hit; query Postgres + cache result if miss.
  • On POST /v1/leaderboards/submit: delete all lb:{trackId}:* keys for the affected track.
  • Cache miss rate is low in production — leaderboard rankings change infrequently.

Local Dev

Redis is included in SimCopilot.Api/docker-compose.yml. Start with:

docker-compose -f SimCopilot.Api/docker-compose.yml up -d redis