PHP APC 潜在的缓存猛击避免了密钥
我在尝试使用 apc_store()
时收到此错误。我用 google 搜索了一下,发现这是 APC 定时炸弹错误,并看到了一些修复建议将 apc.slam_defense = Off;
添加到 php.ini。
我需要知道这是否是由于编程错误而发生的,如果是,如何修复它。
这是代码段:
if ($data = apc_fetch("foo")) {
$an_array = $data;
} else {
/* couple of lines */
apc_store("circles", $an_array); // This is where I get the error
}
该脚本将在我部署的系统中被频繁调用。
我希望我已经提供了足够的信息,
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在
php.ini
中设置apc.write_lock = 1
和apc.slam_defense = 0
应该可以解决该问题。Setting
apc.write_lock = 1
andapc.slam_defense = 0
inphp.ini
should fix the problem.从 APC 3.1.3 开始,似乎存在一个错误(http://pecl.php.net/bugs /bug.php?id=16814),当 slam 防御开启时以及当您尝试写入已存在的密钥时,会发出警告。
似乎还没有修复。
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.
最新版本的 APC 似乎解决了问题,您可以使用 PECL 更新 APC
Last versions of APC seems to resolve problem, you can update APC with PECL
这些说明将根据 PHP 的安装方式而有所不同。
但是,在您的
/etc/php5/cgi/conf.d/extensions.ini
文件(或apc.ini
或php.ini
)添加extension=apc.so
后,您可以禁用 slam 防御例如,这是我使用的配置。
These instructions will vary based on how PHP is installed.
But, in your
/etc/php5/cgi/conf.d/extensions.ini
file (orapc.ini
, orphp.ini
) after you have added yourextension=apc.so
you can disable the slam defenseFor example, this is my configuration that I use.