PHP APC 潜在的缓存猛击避免了密钥

发布于 2024-10-17 13:26:28 字数 467 浏览 3 评论 0原文

我在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烟花易冷人易散 2024-10-24 13:26:28

php.ini 中设置 apc.write_lock = 1apc.slam_defense = 0 应该可以解决该问题。

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

黎夕旧梦 2024-10-24 13:26:28

从 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.

农村范ル 2024-10-24 13:26:28

最新版本的 APC 似乎解决了问题,您可以使用 PECL 更新 APC

pecl upgrade apc

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

pecl upgrade apc
笔落惊风雨 2024-10-24 13:26:28

这些说明将根据 PHP 的安装方式而有所不同。

但是,在您的 /etc/php5/cgi/conf.d/extensions.ini 文件(或 apc.iniphp.ini )添加 extension=apc.so 后,您可以禁用 slam 防御

例如,这是我使用的配置。

[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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文