On Apr 28, 6:03 am, Nick Johnson <[email protected]> wrote:
> On Sat, Apr 25, 2009 at 6:16 AM, Melvin <[email protected]> wrote:
>
> > I am building a new web site and it does not have significant load
> > yet.
> > The strange thing is that
> >   1. my web site does not respond at the beginning;
>
> This is usually caused by not having the 'main invocation' stanza at
> the bottom. The first time an app server runs your code, it simply
> imports the file and expects you to execute the main function.
> Subsequent times, it executes main() directly. If you have a main
> function, but no invocation, nothing gets run on the initial request.
> If it's not there already, try adding this to the bottom of your
> request handler:
>
> ---
> if __name__ == '__main__':
>   main()
> ---
>
> >   2. then my cached objects kept getting lost
>
> Memcache doesn't provide any guarantee how long it will cache data for
> - that's why it's a cache and not an authoritative store. You should
> be regenerating cached objects that don't exist in the request that
> needs them - you can't generate them elsewhere and expect them to be
> consistently accessible.
>

Just to complete with a reference, check this link:
http://code.google.com/appengine/docs/python/memcache/usingmemcache.html

specially this part:
def get_data():
  data = memcache.get("key")
  if data is not None:
    return data
  else:
    data = self.query_for_data()
    memcache.add("key", data, 60)
    return data

Basically, encapsulate every query within a function like above...

"By default, values stored in memcache are retained as long as
possible."
For me, this is working exactly as expected.

> -Nick Johnson
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to