Google Memcache Is Super Simple

I think Google as a company tries to make everything simple. I love how easy they make caching integration with their platform.

As a simple example, let’s just say you want to cache the home page to your web site for 24 hours.  If your home page doesn’t change often, but is rather intensive to load when someone asks for it, caching it will speed things up pretty dramatically for anyone that accesses it later.

In this case, the previously rendered HTML is loaded from cache if available.  Otherwise, the HTML is rendered from a Jinja template, stored in cache for the next time and then provided.  Simple.

from google.appengine.api import memcache

if memcache.get('yourindexpage'):



template = jinja_environment.get_template('/index.html')

renderedhtml = template.render()

memcache.set('yourindexpage', renderedhtml, 86400)


Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: