gpt4 book ai didi

haskell - 持久性:如何让 I 处于 ACID 状态

转载 作者:行者123 更新时间:2023-12-01 21:43:29 25 4
gpt4 key购买 nike

假设我在事务中执行以下步骤:

  • 从数据库读取一些数据A
  • 根据它进行一些计算
  • 将一些数据B写入数据库

如果A同时发生变化,是否有可能导致本次交易失败?

简而言之:如何在持久包中实现隔离?

最佳答案

我自己没有使用过persistent,但是Yesod book提到了

One important thing to note is that everything which occurs inside a single call to runSqlConn runs in a single transaction. This has two important implications:

  • For many databases, committing a transaction can be a costly activity. By putting multiple steps into a single transaction, you can speed up code dramatically.

  • If an exception is thrown anywhere inside a single call to runSqlConn, all actions will be rolled back (assuming your backend has rollback support).

这是否为您提供隔离保证可能取决于给定的后端是否为事务提供隔离保证。

关于haskell - 持久性:如何让 I 处于 ACID 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16323083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com