SET NX
The Redis SET option that writes a key only if it does not exist, as one atomic command. Exactly one of many concurrent callers wins, which makes it a claim or a lock; EX adds an expiry so a forgotten claim cannot live forever.
Minimal example
SET idem:42:abc pending NX EX 86400Learn this concept
Lesson 3.9 · Idempotency keysUsed in exercises
Exercise 3.10 · POST /v1/orders: idempotent checkout Exercise 5.8 · Rider assignment worker Exercise 5.11 · Order location stream Exercise 8.2 · Stock reservation service Exercise 8.12 · Engineering walkthrough packagePrerequisite conceptsIdempotency key
RelatedIdempotency key