gpt4 book ai didi

java - 谷歌数据存储查询返回陈旧数据

转载 作者:行者123 更新时间:2023-12-04 05:09:00 25 4
gpt4 key购买 nike

我正在使用 Google App Engine,当我从数据存储中删除并再次列出结果时,我恢复了陈旧数据。
有什么问题?
这是我使用的代码。

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”。

在此处阅读更多信息:https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency

关于java - 谷歌数据存储查询返回陈旧数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15123307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com