祖先在谷歌应用程序引擎数据存储中的目的是什么? [英] What is the purpose of ancestors in the google app engine datastore?

查看:84
本文介绍了祖先在谷歌应用程序引擎数据存储中的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在玩谷歌应用程序引擎及其数据存储,并使用引用属性创建了数据模型和关系。

然而我不清楚祖先与数据存储的概念。他们的目的是什么?为什么我应该使用它们?它们与数据存储实体的引用属性有什么关系?实体组/祖先的另一个好处是创建强一致性的岛屿(而不是最终一致性)。



例如,您可以拥有一个项目及其任务。如果没有祖先,您可以关闭任务,回到项目的任务列表屏幕,并查询打开的任务。由于最终一致性,您刚刚关闭的任务仍可能显示。该查询可能已经被更新仍未被复制的服务器所解析。



但是,对于祖先而言,您可以获得强大的一致性。因此,您将项目作为项目任务的祖先,而不是从任务到项目的简单外键。现在,当查询任务时,您通过提供项目密钥将其作为祖先查询。结果将是非常一致的,您刚刚关闭的任务将永远不会成为结果的一部分。


I have been playing around with google app engine and its datastore recently and created a datamodel and relationships using reference properties.

However I am unclear about the concept of ancestors wrt the datastore. What is their purpose and why should I use them? How do they relate to reference properties of datastore entities?

解决方案

Another benefit of entity groups/ancestors is to create islands of strong consistency (as opposed to eventual consistency).

For instance, you could have a project and its tasks. Without ancestors, you could 'close' a task, go back to the tasks list screen for the project, and do a query for open tasks. The task you just closed could still show up because of eventual consistency. The query may have been resolved against a server where the update still hasn't been replicated.

However, with ancestors you get strong consistency. So, instead of a simple foreign key from task to project, you make the the project the ancestor for the project tasks. Now, when querying for tasks, you make it an ancestor query by also providing the project key. The result will be strongly consistent and the task you just closed won't ever be part of the result.

这篇关于祖先在谷歌应用程序引擎数据存储中的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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