高效查询策略:仅键查询+应用程序引擎中的内存缓存?
我目前通过内存缓存中的键将所有实体缓存在我的 appengine 数据存储中。
将所有查询作为 KEY ONLY 查询进行,然后从内存缓存中获取实际实体对我来说是否更有效?显然,对缓存中丢失的实体进行批量获取。一般来说,这比从返回整个实体的数据存储中执行简单查询更有效。
I currently cache all my entities in my appengine datastore by key in memcache.
Is it more efficient for me to do all my queries as KEY ONLY queries and then getting the actual entities from memcache? Obviously doing a batch get on entities that are missing from cache. In general is that more efficient that doing a simple query from the datastore that returns the entire entity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这样做可能会稍微便宜一些,但由于您可能必须至少获取内存缓存中缺少的一个实体,因此使用这种方法不会节省太多时间。更好的解决方案是将查询结果存储在 memcache 中,这样您就可以使用单个 memcache get 来获取结果集。
Doing this may be marginally cheaper, but since you'll probably have to fetch at least one entity that was missing from memcache, you won't save much time with this approach. A much better solution is to store the result of a query in memcache, so you can fetch the result set with a single memcache get.
是的。它更快,而且更便宜。
http://code.google.com/appengine/kb/postpreviewpricing.html#operations_charged_for
Yes. It's faster, and less expensive.
http://code.google.com/appengine/kb/postpreviewpricing.html#operations_charged_for
是的,仅键查询更便宜,因为它们只需从索引中读取。
如果您要将实体存储在内存缓存中,请务必将它们序列化为首先是 protobuf。
Yes, key-only queries are cheaper because they only have to read from an index.
If you're storing entities in memcache, be sure to serialize them to protobufs first.