1
votes

How would one return all the values stored within the memcache? I have tried using entrySet() and values() methods on the cache but both result in an java.lang.UnsupportedOperationException.

Ideally, I need to return all the entities stored within the cache and bulk save them to the datastore - is this possible?

Thanks

1
Purely out of morbid curiosity, why do you want to do this? - Nick Johnson
I have a resource which is requested very frequently, this resource performs 3 datstore GETs and 3 PUTs. As a result I am using a huge number of datastore RPCs each day and want to reduce this. My plan was to store entities in the memcache for a few minutes (updating the entities when needed) and then batch save these to the datastore. I'd then clear the cache and restart the process again. - Mylo
As I mentioned on the other question, you really don't want to do that - there's a high chance you'll lose data. - Nick Johnson
I don't mind losing data every so often, I would rather reduce the number of datastore calls dramatically and risk losing data periodically than pay the huge fees I'm forecast. If this is not possible fine, but if there is a way to implement a similar solution I'd love to hear it. - Mylo
In that case, you probably want to read this blog post: blog.notdot.net/2010/04/… - Nick Johnson

1 Answers

1
votes

Given the MemcacheService low-level documentation, I don't think it's possible to do so.

This is also supported by the JCache Features Not Supported section of the docs:

An app cannot dump the contents of the cache's keys or values.

(Note: I work for Google. but please don't take this as a response from Google. I haven't used AppEngine much myself.)