Hello I want to know if in the appengine env the things I did is usefull
Because I don’t know why this page is very slow.
class Foo(db.Model):
id = db.StringProperty(multiline=True)
name = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
description = db.TextProperty()
carac = db.StringProperty(multiline=True)
class FoosPage(webapp.RequestHandler):
def get(self):
foos = memcache.get("all-foos")
if foos is None:
foos = Foo.all()
size = foo.count()
else :
size = len(foo)
foosTab=[]
for i in range(size) :
foosTab.insert(i,foos[i])
memcache.set("all-foos", foosTab, 60)
template_values = {
'foos': foos
}
path = os.path.join(os.path.dirname(__file__) + '/../templates/', 'foos.html')
self.response.out.write(template.render(path, template_values))
You have the
memcache.set()inside the loop. That’s a lot of unnecessary traffic to thememcacheservice. Do it once, after the loop.Further, the way you have that coded, there’s no need for establishing
size.or, more idiomatically
That’ll save you doing a separate
count().