Memcache is not "Shared Memory" It is a cache that is sometimes shared. Writes to memcache are not guaranteed, and nor are reads. Cache flushes can happen at any time. It doesn't happen often, but I have put things in memcache and tried to read them 6 lines of code later and they weren't there. You ALWAYS have to Try the read, and then try something else if your value isn't there.
From: [email protected] [mailto:[email protected]] On Behalf Of atarno Sent: Thursday, September 22, 2011 12:12 AM To: [email protected] Subject: [google-appengine] memcache distribution hi folks, i'm puzzled by memcache related logs i see and need your advice. i'm running a java app. i use memcache as a holder of some static variables accessed and changed by different modules. i do it, because as far as i understand such changes will apply to all distributed application instances. the initialization of the memcache is done within an init() method of a servlet flagged with <load-on-startup>. i have a following piece of code there: if(CacheManager.getInstance().getCache("static_vars") == null) { CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory(); Cache cache = cacheFactory.createCache(Collections.emptyMap()); CacheManager.getInstance().registerCache("static_vars", cache); cache.put("var1", 0); cache.put("var2", 9302); ..... } now, i'm watching the logs and i see two requests arriving within 2 seconds. the first one targets an existing instance and everything goes as expected, but the second one triggers a creation of new servlet instance that loads the cache. i guess it happens because another application instance is created. the problem is that i see that in this new instance CacheManager.getInstance().getCache("static_vars") == null. the new instance does not recognize that a memcache with this name already exists and therefore does not use the values that were set there by first instance. what's my problem here? thanks in advance. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/sjMKymw8h7sJ. 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?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
