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 view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/O3LLhC6ncbwJ.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to