Idempotency on writes
- Problem
- A client that retries a POST after a timeout must not create the issue twice.
- Decision
- A middleware using SET key value NX EX ttl in Redis; the first request wins and stores the response, duplicates get the already-computed response.
- Why
- Redis is coordination and deduplication, not the source of truth. Only 2xx responses are cached, and the lock has a short TTL so it does not stay locked if the process dies.