Sorry I forgot a "return"
The example of use is:
def get_items(self):
return model.Item.all().order('-creation_date').fetch(10)
I copied the wrong thing because I'm also trying to cache chunks of
HTML
def get_items(self):
items = model.Item.all().fetch(10)
return self.render_chunk('templates/index-items.html', {'items':
items})
On Oct 8, 4:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I have this funcion to cache things:
>
> def cache(self, key, function, timeout=0):
> logging.debug('looking for %s in the cache' % key)
> data = memcache.get(key)
> if data is not None:
> logging.debug('%s is already in the cache' % key)
> return data
> else:
> data = function.__call__()
> logging.debug('inserting %s in the cache' % key)
> memcache.add(key, data, timeout)
> return data
>
> An example of use:
>
> items = self.cache('index_items', self.get_items)
>
> def get_items(self):
> items = model.Item.all().order('-creation_date').fetch(10)
>
> With the SDK it works. But when uploading the application I just see
> messages saying that nothing is in the cache. I never see "xxx is
> already in the cache".
>
> I have cached all the queries in my main page because it is 6000
> megacycles of average CPU. But if the caching is not working I don't
> know what I can do. I have also tried to cache chunks of HTML, but it
> still doesn't cache anything. In the SDK I go to the memcache viewer
> and I see the chunk of HTML cached if I put the key I use to store it
> in the cache.
>
> The debug messages says me that is not finding anything in the cache.
> And also the chunks of HTML write a tiemstamp and in the development
> environment (localhost) I see always the same timestamp until I call
> to memecache.delete but on the appspot page I always see a different
> timestamp so I'm sure it is caching nothing.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---