实体集团如何助力交易?

发布于 2024-11-16 16:59:25 字数 158 浏览 2 评论 0原文

在 Google App Engine 中,事务中的所有数据存储区操作都必须对同一组内的实体进行操作。

我不明白为什么这对交易来说是一个有用的限制。这似乎没有必要,因为数据存储可以根据事务中发生的情况知道要锁定哪些实体。

将实体分组在一起如何改善事务期间数据存储的操作?

In Google App Engine, all datastore operations in a transaction must operate on entities within the same group.

I don't understand why this is a useful constraint for transactions. It seems unnecessary since the datastore could know which entities to lock based on what happens in the transaction.

How does grouping entities together improve datastore's operations during transactions?

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

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

发布评论

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

评论(1

人间☆小暴躁 2024-11-23 16:59:25

将 App Engine 的数据存储区视为一个巨大的哈希图很有用。你所能做的就是放置、获取和获取。删除键值对。通常键是自动创建的,并且通常值是序列化对象,但它仍然是一个巨大的键值对存储。哈希图。

现在这个大哈希图有一个(而且只有一个)交易选项:您可以一次以原子方式操作一个键值对。没有选择、如果或但是——交易只适用于单个货币对。

当然,你的价值可以是任何东西。它不一定是单个对象。它可以是对象的分层树。那是一个实体组。这是一个技巧,“我必须在事务中操作这些对象,因此我必须使它们看起来像单个值。我只需将它们粘贴到父对象中并存储它。”

因此,实体组并不是作为进行事务的有用方式而创建的。实体被分组,因为这是将它们放入事务中的唯一方法。

It's useful to think of App Engine's datastore as a giant hashmap. All you can do is put, get & delete key-value pairs. Often the key is auto-created, and usually the value is a serialized object, but it's still all a humungous key-value pair store. A hashmap.

Now this big hashmap has one (and only one) option for transactions: you can atomically manipulate one key-value pair at a time. No choices, ifs or buts - a transaction is something that applies to a single pair.

Of course, your value can be anything. It doesn't have to be a single object. It could be a hierarchical tree of objects. That's an entity group. It's a trick that says, "I have to manipulate these objects in a transaction, so I'll have to make them look like a single value. I'll just stick them into a parent object and store that."

So entity groups aren't created as a useful way of doing transactions. Entities are grouped because it's the only way to put them in a transaction.

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