php-apcu (CGI/FastCGI) apc_fetch always return false

我是研究僧i 提交于 2019-12-13 07:24:28

问题


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?

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'));
?>

Steps to reproduce:

  1. Open http://server/test-apc.php to call apc_store
  2. Open http://server/test-apc.php?get to receive stored data using apc_fetch

BTW: apc_cache_info('user') shows it properly with first request, second is empty

Relevant packages (OS: Debian 3.2.63):

  • Apache 2.2.22 (mpm-prefork, suexec-custom, wrapper)
  • php5.5 as CGI
  • php5-apcu 4.0.7
  • (and dependencies)

回答1:


The module php-apcu is not fully compatible with CGI/fcgid.

Possible reason: CGI/fcgid executes the php interpreter as a new instance on every HTTP REQUEST. So apcu/apc cannot recover the user caches.

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/ (down atm - 2015-09-02)



来源:https://stackoverflow.com/questions/32270449/php-apcu-cgi-fastcgi-apc-fetch-always-return-false

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