如果没有数据存储争用的代价,我可以享受亲子关系的好处吗? [英] Can I have the benefit of parent-child relations without the cost of datastore contention?

查看:104
本文介绍了如果没有数据存储争用的代价,我可以享受亲子关系的好处吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设:
1)Google AppEngine具有实体组的概念。
2)实体组中的实体形成一棵树。然而,据我所知,每一个put()对该树中的任何实体都会锁定整个树(不仅仅是直接父对象)一段时间。
3)用户可以写ca.每秒5次到树上。
4)没有办法产生非锁定的行为(即通过使它们成为无索引的属性)

Assumptions: 1) Google AppEngine has the concept of Entity Groups. 2) Entities in an entity group form a tree. However, as far as I understood, every put() to any entity in that tree will lock the whole tree (not just the immediate parent) for a while. 3) Users are allowed to write ca. 5 times per seconds to the tree. 4) There is no way to have a non-locking behaviour (i.e. by making them unindexed properties)

想出一个聪明的主意我自己的父母子模型不使用内置的Key函数(因为那些将创建实体组),而是使用我组成的一些snytax对齐方式?这将允许我通过query compute 父键来检索child实体。

Would it be a smart idea to come up with my own parent-child model that does not use the built-in Key-functions (as those would create entity groups) but instead use some snytax convetions that I made up? This would allow me to retrieve a "child" entity via a query an compute the parent key.

推荐答案

实体组使用的祖先关系可以通过使用父实体的引用/键列表在您自己的代码中建模。根实体将没有,根的孩子将在他们的列表中只有根实体,他们的孩子将有根和他们的直接父母,等等。这是如何在App Engine中实现祖先以进行索引,并且允许您进行相同类型的查询。

The ancestor relationship used by entity groups can be modeled in your own code by using a list of references/keys to parent entities. Root entities will have none, children of roots will have just the root entity in their list, their children will have the root and their immediate parent, and so forth. This is how ancestors are implemented in App Engine for indexing purposes, and it'll permit you to make the same sorts of queries.

这篇关于如果没有数据存储争用的代价,我可以享受亲子关系的好处吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆