Hi Eric,
Try modifying your import like this:
import mymodule
mymodule= reload(mymodule) # Prevent caching of mymodule
See if that works. It worked for me in another context.
DB
----- Original Message -----
From: "Eric Ka Ka Ng" <[email protected]>
To: <[email protected]>
Sent: Sunday, February 14, 2010 6:30 AM
Subject: Re: [google-appengine] Re: how large data can i use in App Caching
and how long will it be cached?
Hi dburns,
according to
http://code.google.com/intl/en/appengine/docs/python/runtime.html#App_Caching
handler script with main() would cache itself and the global env as an
imported module
however, in my case, I have a variable defined inside a module that
would be imported (and cached) , but i would like to have that
variable be re-initialized in every requests. In particular, with this
example
### mymodule.py
counter = 0
def increment():
global counter
counter += 1
return counter
### myhandler.py
import mymodule
print "Content-Type: text/plain"
print ""
print "My number: " + str(mymodule.increment())
print "My number: " + str(mymodule.increment())
the variable "counter" is cached and subsequent requests use the
value from the previous request
but for my case, I would like to "disable" the caching and to have
"counter" being re-initialized to 0 in every request. The 1st
str(mymodule.increment()) always gives 1, and the 2nd always gives 2
any way to achieve this?
- eric
On 14 February 2010 01:52, dburns <[email protected]> wrote:
In Python at least, GAE looks for a function called main() to enable
app caching. Simply rename main() to something else.
On Feb 13, 6:41 am, Eric Ka Ka Ng <[email protected]> wrote:
is it possible to 'disable' the app caching behavior?
- eric
On 12 February 2010 17:48, saintthor <[email protected]> wrote:
> see the demo in this page:http://code.google.com/intl/en/appengine/
> docs/python/runtime.html#App_Caching
> ### mymodule.py
> counter = 0
> def increment():
> global counter
> counter += 1
> return counter
> ### myhandler.py
> import mymodule
> print "Content-Type: text/plain"
> print ""
> print "My number: " + str(mymodule.increment())
> do you mean if the site has not accessed for some minutes, counter
> will be reset to 0?
> On 2月12日, 下午4时24分, Tim Hoffman <[email protected]> wrote:
>> App caching could last as little as a few minutes if your site is not
>> used.
>> In addition if multiple instances are run then only one instance will
>> have the counter with the correct value.
>> You should store your obj in the datastore and cache it in memcache.
>> module level caching is really only useful for cacheable things for
>> each instance,
>> for example compiled templates.
>> T
>> On Feb 12, 3:34 pm, saintthor <[email protected]> wrote:
>> > ### mymodule.py
>> > counter = LargeObj()
>> > ### myhandler.py
>> > import mymodule
>> > print "Content-Type: text/plain"
>> > print ""
>> > print "My number: " + str(mymodule.counter)
>> > if sizeof counter is greater than 1M, can it work?
>> > if there is no request for days, will counter still be cached?
> --
> 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=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.
--
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.
--
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.