# idempotent

**IPA**: /ˌaɪdəmˈpoʊtənt/ (US) | /ˌɪdəmˈpəʊtənt/ (UK)

**词性**: adjective, noun

---

## 释义

### adj. 幂等的；重复执行结果不变的

**en**: (of a mathematical operation or computer function) having the property that repeating the operation produces the same result as performing it once.

**zh**: （指数学运算或计算机函数）具有这样的性质：重复执行与执行一次产生相同的结果。

> "In REST API design, GET and PUT are idempotent methods, while POST is not."
> "在 REST API 设计中，GET 和 PUT 是幂等方法，而 POST 不是。"

> "To ensure idempotent payment processing, we attach a unique idempotency key to each request."
> "为了确保支付处理的幂等性，我们为每个请求附加一个唯一的幂等键。"

### n. 幂等元（数学术语）

**en**: An element of a set that, when combined with itself under a given binary operation, yields itself.

**zh**: 集合中的一个元素，在指定二元运算下与自身运算后仍等于自身。

---

## 习语 / 复合词

- **idempotency key** — 幂等键（用于防止重复请求的唯一标识符）
- **idempotent operation** — 幂等操作
- **idempotent function** — 幂等函数
- **idempotency window** — 幂等窗口（指幂等键的有效期）

---

## 词源 Etymology

**en**: From Latin *idem* ("the same") + *potentem* ("powerful, able"), from *posse* ("to be able"). Coined in the 1870s by American mathematician Benjamin Peirce in the context of linear algebra — describing an element that "has the same power" as itself when multiplied or raised to a power.

**zh**: 源自拉丁语 *idem*（"相同"）+ *potentem*（"有力的、能够的"），词根 *posse*（"能够"）。19 世纪 70 年代由美国数学家 Benjamin Peirce 在线性代数中首创——描述一个元素与自身相乘或乘方后"具有相同的力量"。

---

## 引语 Quotations

> "The concept of idempotence is central to the design of fault-tolerant distributed systems."
> "幂等概念是设计容错分布式系统的核心。"
> — Martin Kleppmann, *Designing Data-Intensive Applications* (2017)

> "An idempotent operation can be repeated any number of times without changing the result beyond the initial application."
> "幂等操作可以重复任意多次，除了首次应用外不会改变结果。"
> — RFC 7231, *HTTP/1.1 Semantics and Content* (2014)

---

## 词族 Word Family

| 词 | 词性 | 释义 |
|---|---|---|
| idempotence | n. | 幂等性（数学用语） |
| idempotency | n. | 幂等性（计算机科学更常用） |
| idempotently | adv. | 幂等地 |

---

## 近义词辨析 Synonyms & Nuance

**idempotent vs. deterministic vs. atomic vs. thread-safe**

- **idempotent**: 精确数学/CS 术语。强调"重复执行安全"——做多少次结果都一样。只用于技术语境。搭配：*idempotent method / operation / key*。
- **deterministic**: 强调"相同输入必得相同输出"，关注可预测性，不关注重复执行。一个 deterministic 函数不一定是 idempotent（如 f(x) = x+1），反之亦然。
- **atomic**: 强调"不可分割"——要么全做，要么不做。关注事务完整性，不关注重复安全。一个 atomic 操作如果做两次还是会改两次状态，就不 idempotent。
- **thread-safe**: 强调"多线程并发不出错"。关注并发访问的正确性。thread-safe 的实现不一定是 idempotent（如计数器++是 thread-safe 的但不是 idempotent 的）。

**一句话记住**：*idempotent* 管"重试不出错"，*deterministic* 管"输入定输出定"，*atomic* 管"要么全成要么不成"，*thread-safe* 管"并发不打架"。

---

## 工作场景例句

**技术评审**:
> "Before we expose this endpoint to partners, we need to make it idempotent — retries after a timeout shouldn't double-charge the merchant."
> "在把这个接口开放给合作方之前，我们需要让它幂等——超时后的重试不应该重复扣商户的钱。"

**面试表达**:
> "At Payful, I made our payment gateway idempotent by introducing idempotency keys stored in Redis with a 24-hour TTL, which eliminated duplicate transactions during network flakiness."
> "在宝付，我通过引入存储在 Redis 中、24 小时 TTL 的幂等键，让支付网关实现了幂等，消除了网络抖动期间的重复交易。"

**架构文档**:
> "Idempotency is not a nice-to-have for financial APIs — it is a correctness requirement."
> "幂等对金融 API 来说不是锦上添花——它是正确性要求。"

---

## 交叉参考 Cross-References

- [[deterministic]] — 确定性的
- [[atomic]] — 原子的
- [[resilient]] — 有韧性的
- [[robust]] — 强健的
- [[trade-off]] — 取舍

---

## 最早用例 First Known Use

1870s, in the mathematical sense, coined by Benjamin Peirce in *Linear Associative Algebra* (1870). The computing sense emerged in the 1970s–80s with the rise of transaction processing and distributed systems.