我在生产服务器上使用APC扩展。我添加了这段代码:
$tmp = apc_fetch('pe_cache_test');
apc_store('pe_cache_test', ($tmp === false) ? 0 : $tmp + 1);
...并注意到'pe_cache_test'对于进一步的请求仍然是空的。这是正常行为,例如由于多个PHP实例?如果每个请求都丢失了缓存数据,APC将如何提高性能?
如果不打算这样做,我在哪里可以找到问题的根源?
谢谢, 鱼骨
编辑2 :
我的主机提供商确认了我的假设。 FCGI在服务器上使用,因此无法共享内存。这不是一个基本问题,使APC绝对对许多生产服务器毫无价值吗?正是因为这个原因,我想知道为什么没人能回答我的问题。即使是变通方法或一些提示也会有很大的帮助。
修改:
配置和版本:
PHP-version:5.2.16
APC-config(注意我使用httpd使用的php.ini但是从cli运行phpinfo(),因此“APC Support”设置为“disabled”)
APC Support => disabled
Version => 3.1.3p1
MMAP Support => Enabled
MMAP File Mask =>
Locking type => pthread mutex Locks
Revision => $Revision: 286798 $
Build Date => Jan 4 2011 13:07:19
Directive => Local Value => Master Value
apc.cache_by_default => On => On
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => no value => no value
apc.num_files_hint => 1000 => 1000
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.shm_segments => 1 => 1
apc.shm_size => 30 => 30
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 0 => 0
apc.write_lock => On => On
我的主机提供商仅提供用于打开/关闭APC的复选框,因为我们在受管服务器上运行该网站。
答案 0 :(得分:3)
如果您的PHP配置为CGI,您将无法使用APC,在这种情况下使用memcached。 APC仅适用于已配置为模块的PHP(例如Apache mod_php)