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

查看:21
本文介绍了自动 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

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

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:API 调用 datastore_v3.RunQuery() 需要更多配额超过可用配额.

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

推荐答案

NDB 只缓存 get by key.我怀疑在您的示例代码中 movies 是一个查询,并且 NDB 不缓存查询,您需要自己做.

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天全站免登陆