HomeChallengesRepsProblemsLeaderboardTake a challenge

The reset code only one pod knows

Password reset works half the time: the code is held in one pod’s memory and checked by whichever pod gets the next request. It also works as many times as you like. Store it where every pod can see it, for a limited time, for one use.

Intermediate20 min on the clock5 graded checks · 100 pointsWorks on One ServerPro
Graded by reading your code against the checklist below.

What you build

  • Store codes in Redis rather than a static dictionary
  • Let Redis expire them
  • Make each code usable once
  • Read and delete in a single step
  • Namespace the keys

Done means

Codes live in Redis with an expiry, are consumed atomically and only once, under namespaced keys.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. Codes are stored outside the process+25State that outlives one process
  2. Redis expires the code+20State that outlives one process
  3. A code works once+25Safe to repeat
  4. Read and delete happen in one step+15State that outlives one process
  5. Keys are namespaced+15State that outlives one process

What it teaches

Safe to repeatintermediate

A request that times out has not necessarily failed — you just did not hear back — so the client retries, and unless the write recognises that it has already happened the customer is charged twice.

The rest of Works on One Server