Google Datastore Querys会返回陈旧的数据 [英] Google Datastore Querys return stale data
本文介绍了Google Datastore Querys会返回陈旧的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Google App Engine,当我从数据存储中移除并重新列出结果时,我恢复了陈旧的数据。
是什么问题?
这里是我使用的代码。
I`m using Google App Engine and when I remove from the datastore and I list again the results, I recover stale data. What is the problem? Here is the code I use.
public void remove(long id) {
EntityManager em = EMFService.get().createEntityManager();
try {
Todo todo = em.find(Todo.class, id);
em.remove(todo);
} finally {
em.close();
}
}
public List<Todo> getTodos(String userId) {
EntityManager em = EMFService.get().createEntityManager();
Query q = em
.createQuery("select t from Todo t where t.author = :userId");
q.setParameter("userId", userId);
List<Todo> todos = q.getResultList();
System.out.println("Listado de " + userId + ": " + todos);
return todos;
}
推荐答案
AppEngine使用HRD,最终一致。
AppEngine use HRD that is "eventually consistant.
请阅读更多: https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency
这篇关于Google Datastore Querys会返回陈旧的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文