I use the APC extension on our production server. I added this code:
$tmp = apc_fetch('pe_cache_test');
apc_store('pe_cache_test', ($tmp === false) ? 0 : $tmp + 1);
... and noticed that 'pe_cache_test' remains empty for further requests. Is this normal behavior, e.g. due to multiple php-instances? If cache-data was lost for every request, how would APC being able to improve performance?
If this behavior is not intended, where can I possibly find the source of problems?
Thanks, fishbone
Edit 2:
My host-provider confirmed my assumptions. FCGI is used on the server and therefore memory cannot be shared. Isn't this an elementary problem and makes APC absolutely worthless for many production servers? Exactly for this reason I'm wondering why nobody can answer my question. Even a workaround or some hints would be a great help.
Edit:
config and versions:
PHP-version: 5.2.16
APC-config (note that I'm using the php.ini used by httpd but running phpinfo() from cli, therefore "APC Support" is set to "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
My host-provider only provides a checkbox for switching APC on/off, because we are running the website on a managed server.
If your PHP is configured as CGI, you will not be able to use APC, use memcached for this case. The APC is only for PHP which has been configured as module (for ex. Apache mod_php)