自动NDB缓存如何工作? [英] How automatic NDB caching works?

查看:123
本文介绍了自动NDB缓存如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站是电影目录。一旦用户登录,我向他/她展示添加到我的数据库的最新影片:

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

它是否被缓存(电影每周添加到数据库,所以应该被缓存)?如何验证(即什么是memcache密钥)?
昨天大约有1000个用户访问了我的网站,并且我得到了

lockquote
OverQuotaError:API调用datastore_v3.RunQuery()需要更多
quota比可用。



解决方案

我怀疑你的示例代码 movies 是一个查询,而NDB不会缓存查询,你需要自己去做。


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.

解决方案

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.

这篇关于自动NDB缓存如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆