Spring Boot interface is idempotent

Idempotent overview

Idempotence is originally a mathematical concept, even if the formula: f(x)=f(f(x)) can be established. Used in the field of programming, it means that for the same system, using the same conditions, one request and repeated requests have the same impact on system resources.

Idempotence is a very important concept in the design of distributed systems. Interfaces with this nature are always designed with such a concept: when an exception occurs in the calling interface and repeated attempts are made, the system will always be unbearable Loss, so this phenomenon must be prevented from happening.

There are many ways to achieve idempotence, and the current request token-based mechanism is widely applicable. The core idea is to generate a unique credential for each operation, which is a token. A token has only one execution right at each stage of the operation, and once the execution is successful, the execution result is saved. For repeated requests, return the same result (error report), etc.

With Redis, it can be easily solved by using idempotent annotations.
Original link: https://www.jianshu.com/p/8ad818f67793

Guess you like

Origin blog.csdn.net/qq_28807077/article/details/109654283