I am currently studying whether it would be suitable for me to use Ehcache in Google App Engine, and I have one specific need.
I am building a game where the game state would be updated every turn. Currently, after each action I update the Memcache, then the datastore. And each turn, I load the state of the game first from the cache, then from the datastore if the cache is empty.
The reason I have to update the datastore each time is because there is no guarantee that the object won’t have been purged from the cache.
My concern is that, most of the time (i.e. as long as the object is not evicted from the cache), all these datastore saves are useless.
I am thus looking for a way to trigger the datastore save only once, before the object is evicted from the cache.
It seems that this is not possible using GAE Memcache. I had a look at Ehcache, but it only provides notifications after the element has been removed. And, as per the documentation, “only what was the key of the element is known”, which doesn’t go well with what I want to do.
Has anyone already faced the same need? How have you handled it?
Thanks in advance for any hint
No, there’s no way to be notified before an element is evicted from cache on App Engine. There’s also no way to install an alternate caching system like EHCache.
Memcache is, as the name implies, a caching system. Even with an eviction mechanism, you shouldn’t ever rely on it as primary storage.