php APC、APCu 和 Opcache 的区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29187601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:17:46  来源:igfitidea点击:

Difference between APC, APCu and Opcache?

phpcachingapcopcache

提问by martyr

I am running a web server with the following packages; php-apc 3.1.7-1 php5-fpm 5.3.10-1ubuntu3.10

我正在运行带有以下软件包的 Web 服务器;php-apc 3.1.7-1 php5-fpm 5.3.10-1ubuntu3.10

However, i have built a new server on Ubuntu 14.04 and seems like php-apc is not available anymore.

但是,我在 Ubuntu 14.04 上构建了一个新服务器,似乎 php-apc 不再可用。

Therefore, APC was the lifeserver for my huge traffic (100 k/daily unique visits)

因此,APC 是我巨大流量(每天 10 万次独立访问)的救命稻草

I am little bit confused about caching mechanisms on PHP. The new server includes these packages: php-apc 4.0.2-2build1 php5-apcu 4.0.2-2build1 php5-fpm 5.5.9+dfsg-1ubuntu4.7

我对 PHP 上的缓存机制有点困惑。新服务器包括这些包: php-apc 4.0.2-2build1 php5-apcu 4.0.2-2build1 php5-fpm 5.5.9+dfsg-1ubuntu4.7

phpinfo() gives me "apc" as emulated. As far i understand, APC is replaced with APCu.

phpinfo() 给了我模拟的“apc”。据我了解,APC 被 APCu 取代。

https://github.com/cepa/kickasscacheI am running this free class for my caching, it really saves alot of cpu/mem in my case. But i can't understand if this is going to same with APCu?

https://github.com/cepa/kickasscache我正在运行这个免费类来缓存,在我的情况下它确实节省了很多 cpu/mem。但我不明白这是否与 APCu 相同?

If its not, how can i setup a proper caching? Because my new server has limited resources and i need a solution.

如果不是,我如何设置适当的缓存?因为我的新服务器资源有限,我需要一个解决方案。

php -v returns

php -v 返回

PHP 5.5.9-1ubuntu4.7 (cli) (built: Mar 16 2015 20:47:39)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

Does it means OPcache enabled by default?

这是否意味着默认启用 OPcache?

回答by maddog

There is no need for APC (or any of the similar sort of bytecode caching extensions like XCache) as of PHP 5.5 and later. The PHP developers directly integrated what they call OPCache into the core of the product. Not only does this provide greater overall product stability, it is officially supported by the PHP developers.

从 PHP 5.5 及更高版本开始,不需要 APC(或任何类似的字节码缓存扩展,如 XCache)。PHP 开发人员直接将他们所谓的 OPCache 集成到产品的核心中。这不仅提供了更高的整体产品稳定性,而且还得到了 PHP 开发人员的正式支持。

If you need a specific feature from APC that is not in OPCache (e.g. APCu functionality), then you should start a discussion on the php-dev mailing list.

如果您需要 OPCache 中没有的 APC 特定功能(例如 APCu 功能),那么您应该在 php-dev 邮件列表上开始讨论。

Finally, a good rule of thumb is to only run versions of PHP that are listed on the php.net homepage. While distros will generally backport security fixes, newer versions of PHP have more useful features. Newer versions of PHP also generally have significant performance benefits that may allow you to bypass needing additional PECL extensions such as APCu.

最后,一个好的经验法则是只运行 php.net 主页上列出的 PHP 版本。虽然发行版通常会向后移植安全修复程序,但较新版本的 PHP 具有更多有用的功能。较新版本的 PHP 通常还具有显着的性能优势,可以让您绕过需要额外的 PECL 扩展,例如 APCu。