I switched to NDB for a new app, which as I understand includes memcache support 'for free'.
So I put an entity in the datastore:
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 then retrieve using
obj = pickle.loads(MyStorage.query(ancestor = ndb.Key('top_level_key', 'second_level_key')).get().pickled_data)
But the delay in testing it when deployed on app engine tells me there's no caching going on (obviously none expected on the first call, but subsequent calls should show a speed up).
I check Memcache Viewer and sure enough, zeroes under every metric. So I'm obviously not getting something regarding free NDB caching. Can someone point out what it is?
NDB will only read from cache when you use .get_by_id()
(or .get()
on a Key). It won't be used when you use .query()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With