简体   繁体   English

如何对 APC 缓存进行碎片整理

[英]How to de-fragment APC cache

Is it possible to de-fragment a APC cache or the only available option is to clear and rebuild it?是否可以对 APC 缓存进行碎片整理,或者唯一可用的选项是清除并重建它?
If we can't de-fragment it, is it a good idea to dump an entire cache clear it and then reload the dump?如果我们不能对其进行碎片整理,转储整个缓存清除它然后重新加载转储是个好主意吗? will this clear the fragmentation?这会清除碎片吗?

APC store opcodes in ram. APC 在 ram 中存储操作码。 It has no fragmentation management.它没有碎片管理。

The only way to deframent is to flush cache.碎片化的唯一方法是刷新缓存。 Use apc_clear_cache() in php script.在 php 脚本中使用 apc_clear_cache()。 Or restart httpd.或者重启httpd。

Note that APC will have to rebuild its cache.请注意,APC 将不得不重建其缓存。

There should be no (or few) fragmentation if you give APC enough memory.如果你给 APC 足够的内存,就不应该有(或很少)碎片。 Check my answer here to see how to guess the required ram What is causing "Unable to allocate memory for pool" in PHP?在此处查看我的答案以了解如何猜测所需的 ram 在 PHP 中导致“无法为池分配内存”的原因是什么?

There is alternative way.有替代方法。 If you install somewhere file called apc.php with password (very important!) you can login on that site and flush opcode and user caches from there.如果您使用密码安装名为apc.php 的文件(非常重要!),您可以登录该站点并从那里刷新操作码和用户缓存。

On Debian 8, install APC:在 Debian 8 上,安装 APC:

sudo apt-get install -y php5-apcu

Then copy apc.php into your web root:然后将apc.php复制到您的 Web 根目录中:

cp /usr/share/doc/php5-apcu/apc.php /var/www/html

Edit the file, modifying the ADMIN_USERNAME & ADMIN_PASSWORD .编辑该文件,修改ADMIN_USERNAMEADMIN_PASSWORD

Then visit the apc.php file in your browser, login, & hit Clear Cache .然后在浏览器中访问apc.php文件,登录,然后点击Clear Cache

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

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