跨组(XG)交易及使用进一步说明

发布于 2024-12-13 03:13:31 字数 491 浏览 3 评论 0原文

GAE 的最新版本规定以下更改:

数据存储

跨组(XG)事务:适合那些需要事务写入的人 多个实体组中的实体(这就是每个人,对吧?), XG 交易就是这样。此功能使用两阶段提交 使跨组写入就像单组写入一样原子。

我想我可以在我不久前创建的项目的代码中使用此更改,但我想了解有关 App Engine 更新的更多信息。我似乎找不到任何额外的信息。那么...

在这次更新中,编码交易发生了怎样的变化?通俗地说,如何实现跨组交易?数据存储交易是否还存在一些需要注意的限制?

我知道这是一个相当模糊的问题。我的问题是,这听起来非常有用,但我不确定如何正确(且有效)使用此更改。

The most recent release of the GAE states the following changes:

Datastore

Cross Group (XG) Transactions: For those who need transactional writes
to entities in multiple entity groups (and that's everyone, right?),
XG Transactions are just the thing. This feature uses two phase commit
to make cross group writes atomic just like single group writes.

I think I could use this change within the code of a project I created a while ago but I would like further information regarding this update to the App Engine. I can't seem to find any additional information. So...

How has coding transactions changed, in regards to this update? In layman's terms, how can I implement a cross-group transaction and are there still some limitations to data store transactions that I need to be aware of?

I know this is a rather vague question. My problem is that this sounds very useful, but I'm not sure how to correctly (and effectively) use this change.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏有森光若流苏 2024-12-20 03:13:31

您读过任何文档吗?听起来你还没有(根据你所说的“我似乎找不到任何其他信息”)。在这种情况下,请查看下面的链接,看看是否还有任何问题。

从概念上讲,进行跨组事务与典型的 GAE 事务非常相似,只是速度较慢,并且仅在 HRD 中可用。请注意,一般来说,GAE 事务(“正常”事务和 XG)都具有与您可能习惯的来自 SQL 数据库的隔离特性不同的隔离特性。第二个链接在 XG 部分之后立即讨论了这一点。

以下是第一个链接的摘录,展示了使用 XG 是多么简单。

from google.appengine.ext import db

xg_on = db.create_transaction_options(xg=True)

def my_txn():
    x = MyModel(a=3)
    x.put()
    y = MyModel(a=7)
    y.put()

db.run_in_transaction_options(xg_on, my_txn)

Have you read any of the docs? It sounds like you haven't (based on you saying "I can't seem to find any additional information"). In that case, check out the links below and see if still have any questions.

Conceptually, doing a cross group transaction is pretty similar to a typical GAE transaction, just slower, and only available in the HRD. Note that in general, GAE transactions, both "normal" and XG have different isolation characteristics than what you may be used to coming from a SQL database. The second link discusses this immediately after the XG section.

Here is an excerpt from the first link showing how simple using XG can be.

from google.appengine.ext import db

xg_on = db.create_transaction_options(xg=True)

def my_txn():
    x = MyModel(a=3)
    x.put()
    y = MyModel(a=7)
    y.put()

db.run_in_transaction_options(xg_on, my_txn)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文