gaeutilities

Utility classes to make working with appengine easier.

Cache

Cache is a caching class built using Big Table as it's storage. Google App Engine doesn't give you any access to storing data directly on a filesystem, so Cache was built to replace that functionality some what. The idea is that you can save CPU cycles and increase application performance by storing pre-generated content and objects in the data store. Like session, cache uses the standard Python methods for container access.

Classes: Session Flash Event Cache
cacheItemStr = This is a string passed to the cache
cacheItemObj = this was set up as a list to test object caching
dynamickey = this is a dynamically created keyname
{'hits': 624L, 'items': 8L, 'bytes': 983L, 'oldest_item_age': 202007L, 'misses': 45L, 'byte_hits': 92958L}

webapp class

class CachePage(webapp.RequestHandler):
  def get(self):
    self.cache = cache.Cache()
    # test deleting a cache object
    del self.cache["sampleStr"]
    # set a string
    if not "sampleStr" in self.cache:
        self.cache["sampleStr"] = "This is a string passed to the cache"
    # store an object
    if not "sampleObj" in self.cache:
        self.cache["sampleObj"] = ["this was set up as a list to test object caching"]
    self.memcacheStats = memcache.get_stats()
    template_values = {
        'cacheItemStr': self.cache["sampleStr"],
        'cacheItemObj': self.cache["sampleObj"],
        'memcacheStats': self.memcacheStats,
    }
    path = os.path.join(os.path.dirname(__file__), 'templates/cache.html')
    self.response.out.write(template.render(path, template_values))

template

    cacheItemStr = {{ cacheItemStr }}<br />
    cacheItemObj = {{ cacheItemObj.0 }}<br />