简体   繁体   English

立即查询已保存的实体有时会返回null-数据存储区

[英]Querying immediately for saved entity returns null sometimes - datastore

I am saving an entity kind 'review' with following properties 我正在保存具有以下属性的实体类型“评论”

review {
  _id : 4e0590ae-7603-44ff-8333-b3d06546914f
  text : 'Nice review'
}

I am saving it with a AJAX call and on success response I am passing _id and querying for saved review in another AJAX call. 我正在通过AJAX调用保存它,并在成功响应时传递_id并在另一个AJAX调用中查询保存的评论。 Sometimes I am getting null which results in NullPointerException. 有时我会得到null,这会导致NullPointerException。 In datastore storing entity takes more time? 在数据存储区中存储实体需要更多时间吗? If takes then the first AJAX call should not return till put operation completes. 如果需要,则在放置操作完成之前,不应返回第一个AJAX调用。 Is there any configuration I am missing? 我缺少任何配置吗?

In datastore, you don't have instantaneous strong consistency. 在数据存储区中,您没有即时的强一致性。 You have eventual consistency while your data replicates and your indices get populated. 在复制数据和填充索引时,最终将具有一致性。

To force consistency, you need either ancestor queries , or get-by-key queries . 为了保持一致性,您需要使用祖先查询按键获取查询

Look up this article for more ideas on how to structure your data. 本文中查找有关如何构造数据的更多想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM