Deleting all records from app engine datastore and flush memcache

162 views
Skip to first unread message

Saurabh Saxena

unread,
Aug 29, 2013, 7:49:48 AM8/29/13
to google-a...@googlegroups.com

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.

Vinny P

unread,
Aug 30, 2013, 1:07:10 AM8/30/13
to google-a...@googlegroups.com
On Thu, Aug 29, 2013 at 6:49 AM, Saurabh Saxena <saxen...@gmail.com> wrote:
I am looking for a way around to flush/clear the memcache.


Hello Saurabh,

Memcache offers the clearAll method to flush all values. See https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService and scroll down to clearAll().

 

On Thu, Aug 29, 2013 at 6:49 AM, Saurabh Saxena <saxen...@gmail.com> wrote:
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.


Note that - depending on the speed of your PC - it may take some time to delete data off the local development datastore. Try giving some time between deleting the data and refreshing the page.
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
 


Reply all
Reply to author
Forward
0 new messages