当前位置:网站首页>Treatment of idempotency
Treatment of idempotency
2022-04-23 15:39:00 【dengk2013】
What is idempotency ? Sending an interface call and sending the same interface message multiple times can get the result that is consistent with the expectation
If there is an interface that provides salary increase , If you call add... Once 500 Yuan , If you don't control the problem of idempotency ,
Keep calling the interface , Then the employee's salary has been increasing
// Inquire about 1 Employee No
Employee employee = employeeService.selectById(1);
// Update salary
employee.setSalary(employee.getSalary() + incrSalary);
// Execute UPDATE statement
employeeService.update(employee)
What's the problem? ? Right , Every time you resend a request 1 No. salary will +500, Idempotency is destroyed
How to solve ? The traditional method is to add pre judgment to the code , That is, by adding a flag and salary increase time
if(! The employee has been paid && Raise time +6 Months < Current system time )
{
Carry out salary adjustment
}
What's wrong with ? There are too many areas for pre judgment , If you don't pay attention, you'll miss This technical problem should not be a factor that interferes with programmers writing business code
We need a non intrusive idempotent solution Building idempotent tables is our general solution Let the brothers concentrate on writing CRUD That's it
advantage : The background service has no code intrusion , No need to modify business logic
shortcoming : The foreground application should be transformed for idempotence Increased architecture complexity , Additional deployment is required Nginx、Redis
版权声明
本文为[dengk2013]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231537380036.html
边栏推荐
- 如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
- 基础贪心总结
- PHP PDO ODBC loads files from one folder into the blob column of MySQL database and downloads the blob column to another folder
- Cookie&Session
- Mumu, go all the way
- Recommended search common evaluation indicators
- Upgrade MySQL 5.1 to 5.68
- What if the package cannot be found
- Summary of interfaces for JDBC and servlet to write CRUD
- Neodynamic Barcode Professional for WPF V11.0
猜你喜欢
regular expression
Basic concepts of website construction and management
自主作业智慧农场创新论坛
CAP定理
WPS品牌再升级专注国内,另两款国产软件低调出国门,却遭禁令
G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
Multitimer V2 reconstruction version | an infinitely scalable software timer
【Leetcode-每日一题】安装栅栏
Functions (Part I)
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
随机推荐
Mysql database explanation (IX)
Do keyword search, duplicate keyword search, or do not match
PHP 的运算符
字节面试 transformer相关问题 整理复盘
MySQL InnoDB transaction
一刷313-剑指 Offer 06. 从尾到头打印链表(e)
字符串最后一个单词的长度
The El tree implementation only displays a certain level of check boxes and selects radio
Go语言切片,范围,集合
Basic concepts of website construction and management
大厂技术实现 | 行业解决方案系列教程
What is CNAs certification? What are the software evaluation centers recognized by CNAs?
What are the mobile app software testing tools? Sharing of third-party software evaluation
Crawling fragment of a button style on a website
移动app测试如何进行?
Machine learning - logistic regression
Mumu, go all the way
Openstack theoretical knowledge
Explanation 2 of redis database (redis high availability, persistence and performance management)
shell脚本中的DATE日期计算