NDB caching does not work in Google App Engine

I switched to NDB for a new application, which, as I understand it, includes memcache support for free.

Therefore, I put the entity in the data store:

class MyStorage(ndb.Model): pickled_data = ndb.BlobProperty() obj = MyStorage(parent=ndb.Key('top_level_key', 'second_level_key'), pickled_data = pickle.dumps(my_attr)) obj.put() 

In other requests, I get with

 obj = pickle.loads(MyStorage.query(ancestor = ndb.Key('top_level_key', 'second_level_key')).get().pickled_data) 

But the test delay when deploying to the application engine tells me that caching does not happen (obviously, no one expected it on the first call, but subsequent calls should show speed).

I check Memcache Viewer and, of course, zeros under each metric. Therefore, I obviously do not get anything regarding NDB caching for free. Can someone point out what it is?

+7
source share
1 answer

NDB will only read the cache when you use .get_by_id() (or .get() for the key). It will not be used if you use .query() .

+14
source

All Articles