I am displaying data from a data store kind in a html table using jsp. I am trying to delete all records from a Google app engine datastore locally using following code :
Query gaeQuery = new Query("Book");
PreparedQuery pq = datastore.prepare(gaeQuery);
List<Entity> list = pq.asList(FetchOptions.Builder.withDefaults());
for(Entity item : list){
datastore.delete(item.getKey());
}
I am able to delete all records by this code. After running this code, I try to refresh the page to see an empty table. But still there are some records left which disappears after a second page refresh.
I think this is causing because the stale data remains in the memcache. I tried googling but not been able to find any solution to clear the memcache soon after deleting all records of a same kind.
I am looking for a way around to flush/clear the memcache.
You can use the
clearAll()
function.https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/AsyncMemcacheService#clearAll() or https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService#clearAll() for details