API interface design Idempotency

table of Contents

Idempotence scene

  • Network latency resulting in repeated submission.
  • Repeat submit the form.

solution

Each time you submit uses a Token, Token temporary and only to ensure

token generation rule (single application): token + UUID

  1. Redis to generate a token stored in the interface before each call.
  2. When the call interface, the generated token into the request header.
  3. Interface header token acquisition request, to redis query token is present, there is delete the token and execute business logic.
  4. If you can not find the token redis not be repeated in the prompt submission.

token generation rules (distributed): token + distributed global id

Guess you like

Origin www.cnblogs.com/lspkenney/p/11422225.html