This is a class that seamlessly caches entities. Everything happens transparently.
All you need to do is:
import datastore_cache
datastore_cache.DatastoreCachingShim.Install()
Then use the datastore as you would without using memcache. All entities will be cached in memcache as they pass through this api proxy. Your get requests will be served out of memcache if there is a hit. The cache is updated through:
- puts
- gets
- queries
Limitations:
- The cache is completely pessimistic in the case of transactions. In case of a request that is part of a transaction:
* gets are not served from the cache
* puts/deletes invalidate those entities from the cache when they commit
* puts/deletes do not change the cache if they rollback
- If your entity keys are larger than the size allowed for memcache keys the cache will fail
Thanks to Nick Johnson for the original idea to do this at the api proxy stub level and the original sketch of the code.
Seems like rewriting it to use the sanctioned "hooks" mechanism would be more likely to work going forward.