PHP APC Potential Cache Slam Averted for Key

房东的猫 提交于 2020-01-01 01:12:49

问题


I'm receiving this error while trying to use apc_store(). I googled it and saw that this was APC timebomb bug and saw some fixes which suggested adding apc.slam_defense = Off; to php.ini.

I need to know whether this has happened because of a programming error, and if yes, how to fix it.

This is the code segment:

if ($data = apc_fetch("foo")) {
    $an_array = $data;
} else {
    /* couple of lines */

    apc_store("circles", $an_array); // This is where I get the error
}

This script will be called frequently in my deployed system.

I hope I've provided enough info

Thanks in advance


回答1:


Since APC 3.1.3, it seems there is a bug (http://pecl.php.net/bugs/bug.php?id=16814), warning are made when slam defense is at on and when you try to write a key that already exists.
Does not seem to be fixed yet.




回答2:


Setting apc.write_lock = 1 and apc.slam_defense = 0 in php.ini should fix the problem.




回答3:


Last versions of APC seems to resolve problem, you can update APC with PECL

pecl upgrade apc



回答4:


These instructions will vary based on how PHP is installed.

But, in your /etc/php5/cgi/conf.d/extensions.ini file (or apc.ini, or php.ini) after you have added your extension=apc.so you can disable the slam defense

For example, this is my configuration that I use.

[apc]
apc.enabled=1
apc.shm_size=48M
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
apc.stat=1
apc.enable_cli=On
apc.write_lock = 1 
apc.slam_defense = 0 # <----- This is the Important Setting


来源:https://stackoverflow.com/questions/4983370/php-apc-potential-cache-slam-averted-for-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!