klenwell information services : AppengineMulticache

Multicache

return to DevAppengine

Multicache is a (nearly) drop-in replacement for App Engine's native memcache interface that allows object larger than the 1 MB limit to be stored.

Currently it has only set and get methods, but extending the library to match the rest of the App Engine memcache client interface is relatively trivial.

Source Code: http://code.google.com/p/appswell/source/browse/appspot/lib/multicache.py
Unit Test: http://code.google.com/p/appswell/source/browse/appspot/test/unit/test_multicache.py
Dev Test: http://code.google.com/p/appswell/source/browse/appspot/test/dev/dev_multicache.py
Demo: http://appswell.appspot.com/demo/multicache

Usage

With memcache

from google.appengine.api import memcache

# cache params
cache_data = some_large_nested_dict
cache_key = 'test_memcache_limit'
cache_len = 60

# save data
memcache.set(cache_key, cache_data, cache_len)


Code above would raise an error like the following:
> ValueError: Values may not be more than 1000000 bytes in length; received 1088171 bytes


With multicache

from lib import multicache as memcache

# cache params
cache_data = some_large_nested_dict
cache_key = 'test_multicache'
cache_len = 60

# save data
memcache.set(cache_key, cache_data, cache_len)

# retrieve data
retrieved_data = memcache.get(cache_key)


References

Google App Engine Memcache Documentation