<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>接口设计 on 星图与尘埃 · Starmap &amp; Dust</title><link>https://zhenda-hub.github.io/tags/%E6%8E%A5%E5%8F%A3%E8%AE%BE%E8%AE%A1/</link><description>Recent content in 接口设计 on 星图与尘埃 · Starmap &amp; Dust</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><copyright>Copyright © 2023-2026 星⁠图⁠与⁠尘⁠埃 Starmap &amp; Dust. All Rights Reserved.</copyright><lastBuildDate>Thu, 03 Dec 2026 22:26:08 +0800</lastBuildDate><atom:link href="https://zhenda-hub.github.io/tags/%E6%8E%A5%E5%8F%A3%E8%AE%BE%E8%AE%A1/index.xml" rel="self" type="application/rss+xml"/><item><title>幂等键：让重试不多扣一次钱</title><link>https://zhenda-hub.github.io/posts/tech/idempotency/</link><pubDate>Thu, 03 Dec 2026 22:26:08 +0800</pubDate><guid>https://zhenda-hub.github.io/posts/tech/idempotency/</guid><description>&lt;p&gt;幂等是同一个操作执行一次和执行多次，对系统状态的影响一样。落到接口上只有一句话：重复请求不产生重复结果。&lt;/p&gt;&#10;&lt;p&gt;之所以必须在意它，是因为网络失败不等于业务没执行。客户端下单，服务端已经扣了款、建了单，回包在回去的路上超时了；客户端只知道「失败」，于是重试，用户就被扣了两次钱。服务端没办法区分「请求没到」和「回包丢了」，唯一可靠的解法是让接口自己能挡住重复。&lt;/p&gt;</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://zhenda-hub.github.io/posts/tech/idempotency/featured.webp"/></item></channel></rss>