$bar = \'BAR\';
apc_store(\'foo\', $bar);
var_dump(apc_fetch(\'foo\'));
Within one request this work.
Now If i try to do a var_dump(a
Your default ttl (apc.ttl) is 0 seconds, that is strange - please try to specify a ttl (in seconds) when storing the value:
apc_store('foo', $bar, 60);
Probably you are running PHP over CGI (instead of FastCGI which you ought to use) - see my answer in another question why APC doesn't work if PHP is running over CGI.
Content of php.ini
apc.enabled="1"
apc.shm_segments="1"
apc.shm_size="128M"
apc.ttl="7200"
apc.user_ttl="7200"
apc.file_update_protection="3"
apc.cache_by_default="0"
apc.max_file_size="1M"
apc.stat="0"
apc.write_lock="1"
apc.report_autofilter="0"
apc.include_once_override="0"
apc.localcache="1"
apc.localcache.size="1024"
apc.coredump_unmap="0"
; Optional, Comment out them later on
apc.num_files_hint="5000"
apc.user_entries_hint="5000"
apc.gc_ttl="3600"
apc.stat_ctime="0"
Content of apctest.php
<?php
$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
?>
Result of apctest.php
string 'BAR' (length=3)
Content of apctest2.php
<?php
var_dump(apc_fetch('foo'));
?>
Result of apctest2.php
string 'BAR' (length=3)
apc.php shows under "Users Cache Entries"
User Entry Label Hits Size Last accessed Last modified Created at Timeout Deleted at
foo 4 656 31.05.2011 12:12:22 31.05.2011 12:05:33 31.05.2011 12:05:33 None [Delete Now]
Software versions:
PHP Version 5.3.6
Server Version: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 SVN/1.6.9 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_fcgid/2.3.5 mod_perl/2.0.4 Perl/v5.8.8
OS: CENTOS 5.6 x86_64 standard