The instance itself will be recreated. If you store a value into Memcache,
it will likely be there the next time you retrieve it. Try this out.

It's not necessary to do what you've done here. When you create a Cache
instance, you're really just creating a client to the cache, and you can do
this each time you need it. There's no need to create a global, long-lived
instance. What you're seeing is perfectly normal - Java objects will not
have a longer lifespan than the JVM. If the JVM dies, so will all the
instantiated objects.

On Tue, May 25, 2010 at 1:28 PM, Rahul <[email protected]> wrote:

> Toby,
>
> I also had the same opinion but as you can see the previous code i
> have given populates the cache again. I guess i am doing something
> wrong. Appreciate if you can look at that and let me know if i have to
> do something which i missing.
>
> Thanks,
> Rahul
>
> On May 25, 4:00 pm, Toby Reyelts <[email protected]> wrote:
> > Rahul,
> >
> > If you're using App Engine's MemcacheService directly (or indirectly, for
> > example through our JSR 107 support), then you are talking to backend
> > memcache instances that have lifetimes separate from your JVMs.
> >
> > I.E. MemcacheServiceFactory.getMemcacheService<
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengi...()
> >
> > does
> > not create a new memcache backend - it just "connects" to an existing
> one.
> > You have one logical memcache backend that is shared between all of your
> > application's JVMs.
> >
> >
> >
> > On Tue, May 25, 2010 at 3:12 PM, Rahul <[email protected]> wrote:
> > > Ikai,
> >
> > > I am not sure what you mean by Memcache instances stays up because i
> > > tried the following code and everytime when a new jvm instance is
> > > created, the cache instance is also created again. Below is the code i
> > > am using, let me know if i am missing anything or not doing anything
> > > correct.
> >
> > > Request comes from the following code:
> >
> > > MyCache _cache = MyCache.getInstance();
> > > redirectUrl = _cache.findInCache(requestedURI);
> >
> > > MyCache Class:
> >
> > >        private static MyCache _instance;
> > >        private Cache cache;
> >
> > >        public static synchronized MyCache getInstance() {
> > >                if (_instance == null) {
> > >                        _instance = new MyCache();
> > >                }else{
> > >                        log.info("Using existing cache instance and NO
> NEW
> > > Instance is
> > > created");
> > >                }
> >
> > >                return _instance;
> > >        }
> >
> > > and in the constructor i am creating new cache fetching everything
> > > from the database.
> >
> > > Also, i have a listener in place which tells me when the new jvm
> > > instance is started.
> >
> > > Thanks,
> > > Rahul
> >
> > > On May 24, 3:56 pm, "Ikai L (Google)" <[email protected]> wrote:
> > > > Memcache instances stay up. They're shared, namespaced (security)
> > > instances
> > > > and will more likely than not outlive the lifecycles of your
> application
> > > > instances.
> >
> > > > On Sun, May 23, 2010 at 11:17 PM, Tristan <
> [email protected]
> > > >wrote:
> >
> > > > > Does anyone know the answer to this:
> >
> > > > > If all the JVMs are killed, does the memcache stick around or is it
> > > > > recycled? (I know memcache expires eventually, just curious if it
> is
> > > > > possible for it to carry data across JVM valley of death)
> >
> > > > > Cheers,
> >
> > > > > Tristan
> >
> > > > > --
> > > > > 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]<google-appengine-java%[email protected]><google-appengine-java%2B
> [email protected]><google-appengine-java%2B
> > > [email protected]>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-appengine-java?hl=en.
> >
> > > > --
> > > > Ikai Lan
> > > > Developer Relations, Google App Engine
> > > > Twitter:http://twitter.com/ikai
> > > > Delicious:http://delicious.com/ikailan
> >
> > > > ----------------
> > > > Google App Engine links:
> > > > Blog:http://googleappengine.blogspot.com
> > > > Twitter:http://twitter.com/app_engine
> > > > Reddit:http://www.reddit.com/r/appengine
> >
> > > > --
> > > > 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]<google-appengine-java%[email protected]><google-appengine-java%2B
> [email protected]>
> > > .
> > > > For more options, visit this group athttp://
> > > groups.google.com/group/google-appengine-java?hl=en.
> >
> > > --
> > > 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]<google-appengine-java%[email protected]><google-appengine-java%2B
> [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> 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]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
Twitter: http://twitter.com/ikai
Delicious: http://delicious.com/ikailan

----------------
Google App Engine links:
Blog: http://googleappengine.blogspot.com
Twitter: http://twitter.com/app_engine
Reddit: http://www.reddit.com/r/appengine

-- 
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