当前位置:网站首页>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
边栏推荐
- PHP PDO ODBC将一个文件夹的文件装载到MySQL数据库BLOB列,并将BLOB列下载到另一个文件夹
- Explanation of redis database (IV) master-slave replication, sentinel and cluster
- 大型互联网为什么禁止ip直连
- Upgrade MySQL 5.1 to 5.67
- 开源项目推荐:3D点云处理软件ParaView,基于Qt和VTK
- JSON date time date format
- 字符串最后一个单词的长度
- 移动app测试如何进行?
- 电脑怎么重装系统后显示器没有信号了
- fatal error: torch/extension.h: No such file or directory
猜你喜欢

Codejock Suite Pro v20. three

Basic concepts of website construction and management

G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction

Krpano panorama vtour folder and tour

What if the server is poisoned? How does the server prevent virus intrusion?

Codejock Suite Pro v20.3.0

Multitimer V2 reconstruction version | an infinitely scalable software timer

For examination

【Leetcode-每日一题】安装栅栏

携号转网最大赢家是中国电信,为何人们嫌弃中国移动和中国联通?
随机推荐
Upgrade MySQL 5.1 to 5.67
Mysql database explanation (8)
控制结构(一)
怎么看基金是不是reits,通过银行购买基金安全吗
多级缓存使用
php类与对象
IronPDF for .NET 2022.4.5455
fatal error: torch/extension.h: No such file or directory
Node.js ODBC连接PostgreSQL
YML references other variables
软件性能测试报告起着什么作用?第三方测试报告如何收费?
JSON date time date format
Mobile finance (for personal use)
PHP operators
Codejock Suite Pro v20.3.0
What are the mobile app software testing tools? Sharing of third-party software evaluation
通过 PDO ODBC 将 PHP 连接到 MSSQL
Openstack theoretical knowledge
ICE -- 源码分析
JVM-第2章-类加载子系统(Class Loader Subsystem)