Stop using the JCache interface. It just adds a useless complicated layer between you and what's really going on. For example, CacheManager.getCache(String) doesn't do what you think it does.
Use MemcacheServiceFactory and MemcacheService. Jeff On Thu, Sep 22, 2011 at 12:11 AM, atarno <zlango....@gmail.com> wrote: > 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 google-appengine@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine+unsubscr...@googlegroups.com. > 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 google-appengine@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.