简体   繁体   English

PHP APC Cache,开箱即用吗?

[英]PHP APC Cache, does it work out of the box?

So this is whats bothering me. 所以这是困扰我的。 I just installed APC cache and Im testing it. 我刚刚安装了APC缓存而我正在测试它。 When using APC Admin interface, in apc.php file, I can see all the info about APC etc. When I go to System Cache Entries I can see that every script i invoke gets written there. 当使用APC Admin界面时,在apc.php文件中,我可以看到有关APC等的所有信息。当我进入系统缓存条目时,我可以看到我调用的每个脚本都写在那里。

So does this means that APC Cache works out of the box? 那么这是否意味着APC Cache开箱即用? I can just install APC cache and it already speeds up my application by caching scripts? 我可以安装APC缓存,它已经通过缓存脚本加速了我的应用程序? And if I want I can then cache variables to make it even faster? 如果我想,我可以缓存变量,使其更快?

Hope you get the question, its probably simple to someone with more experience with APC. 希望你能得到这个问题,对于有更多APC经验的人来说,这可能很简单。

Its I know i can add some variables to cache, and then get them out and that will speed up my app. 它我知道我可以添加一些变量缓存,然后把它们拿出来,这将加快我的应用程序。 But is it true, that APC will speed up the app and cache scripts all by him self? 但这是真的吗,APC会加速应用程序和缓存脚本全部由他自己? And is there any good documentation where I could learn more about APC? 是否有任何好的文档可以让我了解更多有关APC的信息?

Yeah, APC "just works". 是的,APC“正常”。 Anyone running PHP in production without APC/(other opcodecache) is missing out on the easiest performance improvement they can readily achieve. 任何在没有APC /(其他操作码缓存)的情况下在生产中运行PHP的人都错过了他们可以轻松实现的最简单的性能改进。

A few caveats though. 但有几点需要注意。

If you are in development, you can still run APC, however, you probably want to enable stat calls. 如果您正在开发中,您仍然可以运行APC,但是,您可能希望启用stat调用。 This means that APC will check the last modified of your files. 这意味着APC将检查您文件的最后修改。

apc.stat = [1|0]

So if you don't have stat calls enabled, and you change a file and APC has already cached it, then it won't observe your changes, and you will continue using the cached opcode. 因此,如果您没有启用状态调用,并且您更改了文件并且APC已经缓存了它,那么它将不会观察您的更改,并且您将继续使用缓存的操作码。

As you have mentioned, APC isn't just for opcode caching, it is also useful for user space caching. 正如您所提到的,APC不仅适用于操作码缓存,它还可用于用户空间缓存。 You have your system cache and your user cache. 您拥有system缓存和user缓存。

You can store things against your user cache by just performing something like: 您只需执行以下操作即可将内容存储在用户缓存中:

apc_store("fooKey", "barValue");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM