-->

How automatic NDB caching works?

2019-07-17 17:34发布

问题:

My website is movies catalog. Once user log in, I show him/her the latest movie added to my database:

movies = Movies.query()
movies = movies.order(-Movies.added)
movie = movies.get(keys_only = True) // get_latest_movie_id

Is it cached (movies are added to the database weekly, so it should be cached)? How to verify that (i.e. what is memcache key)? Yesterday about 1000 users visited my site and I've got

OverQuotaError: The API call datastore_v3.RunQuery() required more quota than is available.

回答1:

NDB only caches gets by key. I suspect that in your example code movies is a query, and NDB doesn't cache queries, you'll need to do that yourself.