Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一种简单的事务实现 - Luyu Huang's Blog #80

Open
luyuhuang opened this issue Jun 18, 2023 · 1 comment
Open

一种简单的事务实现 - Luyu Huang's Blog #80

luyuhuang opened this issue Jun 18, 2023 · 1 comment

Comments

@luyuhuang
Copy link
Owner

https://luyuhuang.tech/2023/06/18/simple-transaction.html

在服务器编程中,事务往往是非常重要的,它的一个很重要的作用就是保证一系列操作的完整性。例如服务器处理某个请求要先后执行 a, b 两个修改操作,它们都有可能失败;如果 a 成功了但 b 失败了,事务会负责回滚 a 的修改。试想如果 a 操作是扣除余额,b 操作是发货,如果发货失败,钱就得退回去。如果服务器使用了支持事务的数据库系统,如 MySQL,事情就很好办。否则的话,实现类似的逻辑会比较棘手,

@Ryogi-Shiki
Copy link

利用C++的析构是不是更方便?程序的一开始用guard保存初始值,不正常退出时利用guard的析构恢复数据。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants