In my previous post, I described a caching solution based on subclassing the db.ReferenceProperty class. This time I want to take this one step further and implement this on the lower level API: apiproxy_stub_map.apiproxy.
You can add hooks to the datastore, as I already showed in a previous (profiling) post. However, in order to return a cached entity instead of one retrieved from the datastore, we need more than a PreCall hook. From a PreCall hook will can not prevent the actual datastore call being made. Maybe we can “trick” MakeSyncCall by removing the keys from the argument list, but that is not a road I want to explore…