关于APC和用户数据的问题
我从来没有费心去查看我的项目的缓存,因为它们通常很小,最多有一百个用户,而且数据总是在变化。
然后,我考虑尝试 Symfony,它警告我 APC 已被 check_configuration.php 脚本禁用。
我去检查什么是APC,发现它的主要用途是操作码缓存,这很好,但它也有用户数据缓存,当数据库中发生任何更改时,我不确定这是否是我想要的本来就是要被看到的,而且它们每隔几分钟就会发生一次。
谁能解释一下如何禁用此用户数据缓存,或者当数据总是在变化时,APC 是否不应该使用?
I have never bothered to look at caching for my projects, because they´re usually small, with a hundred users at most, and the data is always changing.
Then, I thought about trying Symfony and it warned me that APC was disabled with the check_configuration.php script.
I went to check what is APC, and saw that it´s main use is opcode caching, which is good, bu that it also has user data caching, which I´m not sure is something I want when any changes in the database are meant to be seen, and they happen every couple of minutes.
Could anyone explain how do I disable this user data cache, or is APC something not to be used when data is always changing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您强制,APC 不会缓存任何用户数据。如果 APC 缓存并提供过时的用户数据,那是因为您已将应用程序设计为这样做。除了操作码缓存之外,它只是一个类似于内存缓存的键值存储——它只缓存您显式放入其中的内容。
如果 symfony 有页面缓存行为,您需要在 symfony 中禁用它,而不是 APC。
APC doesn't cache any user data unless you force it to. If APC caches and serves stale user data, that's because you've designed your application to do so. Outside of opcode caching, it's just a key-value store somewhat comparable to memcache -- it only caches what you explicitly put in it.
If symfony has page caching behavior, you need to disable that in symfony, not APC.
我不使用 APC,而是使用 EAccelerator,但概念是相同的。
操作码缓存通常都很好。
如果您的应用程序不是 RESTful,则内容缓存会很棘手。您需要命名空间和输出之间保持一致的关系,以使缓存有意义。
例如,如果您有一个 RSS 提要,网址为 http://example.com/rss.php 并且内容会定期更改,但 URL 不会更改,缓存比使用 http://example 复杂得多.com/rss.php?time=XXXXXXXXXXUTC
如果您只想防止对使用大量资源且很少更改的 URL 进行 DOS 攻击,您可以为内容缓存设置超时,并接受它或多或少会是最新的。
I don't use APC, I use EAccelerator instead, but the concepts are the same.
Opcode caches are generally good.
Content caching is tricky if your application isn't RESTful. You need a consistent relationship between your namespaces and your output to make caching meaningful.
For example if you have an RSS feed at an url http://example.com/rss.php and the content changes regularly without the URL changing, caching is much more complex than if you used http://example.com/rss.php?time=XXXXXXXXXXUTC
If all you want to do is prevent DOS attacks on an URL which uses a lot of resources and changes rarely you can set a timeout for the content cache, and accept that it will be more-or-less up to date.