使用php apc模块需要注意的几点

本文探讨了APC模块在PHP应用中的最佳实践,强调其适用于缓存变化频率极低的内容,并分享了一线开发者遇到的问题及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自: http://www.ooso.net/index.php/archives/301

 

在maillist中看到Rasmus的一段对于php APC模块的发言。作为APC的作者,他的见解应该是很有参考价值的。

APC will probably be 20-30% faster, but if you are writing to it frequently it can cause problems. The APC cache is best for things that change very rarely. And by very rarely I mean days, not hours or minutes.

Because of the way APC does an anonymous file-backed mmap where I unlink the file at startup to get process-death protection, it isn’t easy to get at the cache from a separate standalone command line script. That can be solved by mmap’ing slightly differently, but in the default config your approach won’t work.

-Rasmus

就是说APC不适合用于频繁写的场合,你最好只用它来保存那种几天都不会更改的内容。否则出了莫名其妙的问题就不好怎么解释了。

在以前的应用中,我确实有将apc用在频繁写的场合,偶尔会出现内存耗尽,进而引起所有http请求卡死,形式一发不可收拾整个服务器当掉。所以现在我仅仅用apc来缓存opcode的php代码,不在程序中显式的调用它,算是相安无事。

APC是什么

Alternative PHP Cache (APC)是一种对PHP有效的开放源高速缓冲储存器工具,它能够缓存opcode的php中间码。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值