Google Datastore Querys return stale data

会有一股神秘感。 提交于 2019-12-07 22:08:58

问题


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;
  }

回答1:


AppEngine use HRD that is "eventually consistant.

Read more here: https://developers.google.com/appengine/docs/java/datastore/structuring_for_strong_consistency



来源:https://stackoverflow.com/questions/15123307/google-datastore-querys-return-stale-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!