写入然后读取实体不会从数据存储中获取实体
我遇到以下问题。我现在用的是低级 谷歌数据存储API而不是JDO,这样我应该在 更好地了解我的代码中到底发生了什么。我是 将实体写入数据存储并随后不久读取它 使用 Jetty 和 eclipse 从数据存储中获取。有时写的 实体未被读取。如果要这样做的话,这将是一个真正的问题 发生在生产代码中。我正在使用 2.0 RC2 API。
我已经尝试过几次,有时实体会被检索到 来自数据存储,有时不是。我正在做一个简单的 提交写入事务后立即查询数据存储。
(如果我通过调试器运行代码,则运行速度足够慢 该实体有机会在第二遍中被读回)。
任何有关此问题的帮助将不胜感激,
问候,
I am having the following problem. I am now using the low-level
google datastore API rather than JDO, that way I should be in a
better position to see exactly what is happening in my code. I am
writing an entity to the datastore and shortly thereafter reading it
from the datastore using Jetty and eclipse. Sometimes the written
entity is not being read. This would be a real problem if it were to
happen in production code. I am using the 2.0 RC2 API.
I have tried this several times, sometimes the entity is retrieved
from the datastore and sometimes it is not. I am doing a simple
query on the datastore just after committing a write transaction.
(If I run the code through the debugger things run slow enough
that the entity has a chance of being read back on the second pass).
Any help with this issue would be greatly appreciated,
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
开发服务器具有与实时服务器上的高复制数据存储相同的一致性保证。 “全局”查询使用的索引仅保证最终与写入一致。要执行具有强一致性保证的查询,必须使用“祖先”键将查询限制为实体组。
典型的技术是将特定于单个用户的数据分组到一个组中,以便用户可以看到仅限于该用户组的查询的更改,并具有强一致性保证。另一种技术是使用更高级的客户端逻辑,在提交更改后立即更新客户端的本地视图,以便用户在更新全局索引的同时立即在 UI 中看到更改。
请参阅有关查询和交易。
The development server has the same consistency guarantees as the High Replication datastore on the live server. A "global" query uses an index that is only guaranteed to be eventually consistent with writes. To perform a query with strongly consistent guarantees, the query must be limited to an entity group, using an "ancestor" key.
A typical technique is to group data specific to a single user in a group, so the user can see changes to queries limited to the user's group with strong consistency guarantees. Another technique is to use fancier client logic to update the client's local view as soon as the change is submitted, so the user sees the change in the UI immediately while the update to the global index is in progress.
See the docs on queries and transactions.