When app server receive a request, it will try to find an exist python
instance that match the handler in app.yaml.

If find one available instance, the server will reuse this instance to
serve this request.
In this case, the following requests can share its global variables(we
call it app cache).

If all instances is busy, or no instance is alive, the sever will
create an new python instance.
In this case, two instances can't share their global variables.

If the python instance idles more than 30 seconds, it will be recycled
at anytime(on average is 1 to 2 minutes), and lost its app cache.
It will also get lost when you deploy.

2009/11/13 Baron <[email protected]>:
> Thanks for the tip.
> Are these global variables cached indefinitely? For example in the
> counter example you linked, will the counter keep increasing or be
> reset to 0 every so often?
>
>
>
> On Nov 13, 2:09 pm, 风笑雪 <[email protected]> wrote:
>> There is an document about app cache and handler 
>> cache:http://code.google.com/appengine/docs/python/runtime.html#App_Caching
>>
>> I can also give you some example code, but you need modify it to fit
>> your framework(maybe a decorator for your handler):
>>
>> main.py:
>>
>> cache = {} # must be a global variable
>>
>> def main():
>>   # get the request path
>>   page = cache.get(path, None)
>>   if page and page['time'] - time() < page['cache_time']
>>     # output page['content']
>>   else:
>>     # generate your page and output it
>>     cache['path'] = {'time': time(), 'cache_time': 60, 'content': content}
>>
>> if __name__ = '__main__':
>>   main()
>>
>> 2009/11/13 GAEfan <[email protected]>:
>>
>> > Thanks, Keakon.  Can you please explain in more detail about your
>> > handler cache?
>>
>> > --
>>
>> > 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 
>> > athttp://groups.google.com/group/google-appengine?hl=.
>>
>>
>
> --
>
> 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=.
>
>
>

--

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


Reply via email to