Hi,

Memcache on GAE is based on JSR-107: see http://jcp.org/en/jsr/detail?id=107

The purpose of jsr 107 is "Specifies API and semantics for temporary,
in memory caching of Java objects, including object creation, shared
access, spooling, invalidation, and consistency across JVMs"

So, memcache is by construction shared across instances

regards

didier

On Jun 15, 8:13 pm, Inderjeet Singh <[email protected]> wrote:
> Hi Folks,
>
> Pardon the somewhat basic question, I did try going through various online
> guides but never really got the answer to this one.
> I am running app-engine with 3 instances. I share data across these
> instances using Memcache. What is the right way to instantiate it such that
> all three appengine instances end up writing to the same cache?
>
> Here is the code that I used:
>  public static synchronized <K, V> Map<K, V> createMemcache(
>       String cacheName, ReadableDuration inactivityTimeout, @Nullable
> CacheListener cacheListener) {
>     try {
>       CacheManager cacheMgr = CacheManager.getInstance();
>       Cache cache = cacheMgr.getCache(cacheName);
>       if (cache == null) {
>         CacheFactory cacheFactory = cacheMgr.getCacheFactory();
>         ImmutableMap<String,Long> env =
>           ImmutableMap.of(GCacheFactory.EXPIRATION_DELTA_MILLIS,
> inactivityTimeout.getMillis());
>         cache = cacheFactory.createCache(env);
>         if (cacheListener != null) {
>           cache.addListener(cacheListener);
>         }
>         cacheMgr.registerCache(cacheName, cache);
>       }
>       return cache;
>     } catch (CacheException e) {
>     }
>
> Any comments? Will this create the shared Memcache as I want it?
>
> Thanks
> Inder

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to