php-apcu(CGI/FastCGI)apc_fetch始终返回false [英] php-apcu (CGI/FastCGI) apc_fetch always return false
问题描述
使用php-apcu( https://github.com/krakjoe/apcu )扩展名时(不是apc)在php CGI环境中,apc_store
中存储的数据为空.
When using the php-apcu (https://github.com/krakjoe/apcu) extension (not apc) in a php CGI environment the stored data fromapc_store
are empty.
任何人都有解决此问题的经验?
Anyone has experiences on how to solve this issue?
示例PHP文件: test-apc.php
Example PHP File: test-apc.php
<?php
$k = 'test';
if(isset($_GET['get'])) {
$result = apc_fetch($k);
echo "Read entry '$k': $result";
} else if(isset($_GET['clear'])) {
echo "Clear entry '$k'";
apc_clear_cache('user');
} else {
apc_store($k, "HelloWord");
echo "Write entry '$k' set";
}
print_r(apc_cache_info('user'));
?>
复制步骤:
- 打开
http://server/test-apc.php
呼叫apc_store
- 打开
http://server/test-apc.php?get
以使用apc_fetch
接收存储的数据
- Open
http://server/test-apc.php
to callapc_store
- Open
http://server/test-apc.php?get
to receive stored data usingapc_fetch
BTW: apc_cache_info('user')在第一个请求中正确显示了它,第二个为空
相关软件包(操作系统:Debian 3.2.63):
- Apache 2.2.22(mpm-prefork,suexec-custom,包装器)
- php5.5作为CGI
- php5-apcu 4.0.7
- (和依赖项)
推荐答案
模块php-apcu与CGI/fcgid不完全兼容.
The module php-apcu is not fully compatible with CGI/fcgid.
可能的原因: CGI/fcgid在每个HTTP请求上将php解释器作为新实例执行.因此apcu/apc无法恢复用户缓存.
Possible reason: CGI/fcgid executes the php interpreter as a new instance on every HTTP REQUEST. So apcu/apc cannot recover the user caches.
模块 mod-fastcgi (用于Debian的非免费软件包)与 php5-fpm 一起可以提供补救措施. 它使用了不同的技术来管理流程.
The module mod-fastcgi (non-free package for Debian) together with php5-fpm can provide remedy. Its uses a different technique to manage processes.
http://php-fpm.org/wiki/(自动取款机-2015-09 -02)
http://php-fpm.org/wiki/ (down atm - 2015-09-02)
这篇关于php-apcu(CGI/FastCGI)apc_fetch始终返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!