Reputation: 4822
Does anyone know if there are any reasons not to use Google Guava Cache library on Google App Engine.
https://code.google.com/p/guava-libraries/wiki/CachesExplained
Particularly using an eviction listener. My concern is that the cache isn't going to be replicated across instances.
Use case would be creating a cache thusly:
LoadingCache<Key, Graph> graphs = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(10, TimeUnit.MINUTES)
.removalListener(MY_LISTENER)
.build();
on the post to an http servlet, using the cache with later posts, and taking some action on removal. I'm concerned there is some nuance with the way app engine handles a cache, and how there is no mention of using an eviction listener in the app engine docs: https://cloud.google.com/appengine/docs/java/memcache/ vs the way its done in the Guava Docs.
update:
from some testing it looks like google guava cache does not work on GAE - and the cache gets evicted at the end of the transaction (30 seconds or so)
thanks in advance.
Upvotes: 0
Views: 575
Reputation: 1674
Well the problem with that is that this Caches are stored on local memory, keep in mind GAE instances are created and destroyed all the time and that's there is no guarantee the requests from a user are served by the same instance.
Unless you can backup this cache with a shared resource (like memcache or datastore) you are out of luck.
Upvotes: 2