应用引擎和Memcache的白痴指南 [英] Idiots guide to app engine and memcache

查看:49
本文介绍了应用引擎和Memcache的白痴指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力查找有关在应用引擎中使用内存缓存的良好教程或最佳做法文档.

I am struggling to find a good tutorial or best practices document for the use of memcache in app engine.

我对文档中介绍的级别感到非常满意.通过ID获取对象,首先检查内存缓存,但在诸如此类的事情上我不清楚:

I'm pretty happy with it on the level presented in the docs. Get an object by ID, checking memcache first, but I'm unclear on things like:

如果您缓存查询,是否存在一种可接受的方法来确保在更新查询中存储的对象时清除/更新缓存.

If you cache a query, is there an accepted method for ensuring that the cache is cleared/updated when an object stored in that query is updated.

使用ReferenceProperties有什么影响?如果缓存带有Bar引用的Foo对象.我的foo.bar是否也在memcache中,是否需要从应用程序的其他部分进行更新也需要清除.

What are the effects of using ReferenceProperties ? If a cache a Foo object with a Bar reference. Is my foo.bar in memcache too and in need of clearing down if it gets updated from some other part of my application.

我不希望在这里得到答案(除非您感觉特别慷慨!),但是非常感谢收到指向我可以阅读的内容的指针.

I don't expect answers to this here (unless you are feeling particularly generous!), but pointers to things I could read would be very gratefully received.

推荐答案

如果您缓存查询,是否有一个 公认的方法来确保 当一个 该查询中存储的对象是 已更新.

If you cache a query, is there an accepted method for ensuring that the cache is cleared/updated when an object stored in that query is updated.

通常,您使用条件包装换行,以从主数据库中检索值(如果该值不在高速缓存中).只要写入数据,也只需包装您的更新以填充高速缓存.那就是如果您需要结果尽可能最新-如果您不担心结果过时,则将有效期设置得足够短,以使应用程序必须从数据库中重新请求数据.主数据库经常足够.

Typically you wrap your reads with a conditional to retrieve the value from the main DB if it's not in the cache. Just wrap your updates as well to fill the cache whenever you write the data. That's if you need the results to be as up to date as possible - if you're not so bothered about it being out of date just set an expiry time that is low enough for the application to have to re-request the data from the main DB often enough.

这篇关于应用引擎和Memcache的白痴指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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