What is Idempotency
Repeated request gives same result
Idempotency is a property of an operation where multiple executions produce the same result as a single execution.
Examples of Idempotent Operations
- GET — retrieving data doesn't change state
- PUT — repeatedly setting a value yields same state
- DELETE — repeatedly deleting an already deleted resource
Non-idempotent Operations
- POST — creates a new resource with each call
- Counter increment
Why It Matters
- Retry requests — safe during network failures
- Distributed systems — simplifies error handling
- Payment systems — protection against double charges
Implementation
- Idempotency Key — unique key for each request
- Storing state of executed operations
- TTL for idempotency keys