然后写入读取实体不会从数据存储中获取实体 [英] writing then reading entity does not fetch entity from datastore

查看:144
本文介绍了然后写入读取实体不会从数据存储中获取实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下问题。我现在使用的是低级的
google数据存储API而不是JDO,这样我应该在
更好的位置查看我的代码中发生了什么。我是
将一个实体写入数据存储区,不久之后使用Jetty和eclipse从数据存储中读取
。有时书面的
实体没有被读取。如果在生产代码中出现
,这将是一个真正的问题。我使用的是2.0 RC2 API。



我已经尝试了几次,有时从数据存储中检索
实体,有时实际不是。我只是在提交写事务之后在数据存储上做了一个简单的
查询。



(如果我通过调试器运行代码,运行速度足够慢
表示该实体有可能在第二次通过时被读回)。

对此问题的任何帮助将不胜感激,



问候,

解决方案

开发服务器具有与高复制数据存储相同的一致性保证活服务器。 全局查询使用的索引只能保证最终与写入一致。要使用强一致的保证来执行查询,必须使用祖先键将查询限制为实体组。

典型的技术是将数据分组组中的单个用户,因此用户可以看到对限于用户组的查询所做的更改,并且具有强大的一致性保证。另一种技术是在提交更改后使用更新的客户端逻辑更新客户端的本地视图,以便用户在更新全局索引时立即看到UI中的更改。



请参阅查询交易


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,

解决方案

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.

这篇关于然后写入读取实体不会从数据存储中获取实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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