我必须错过一些明显的东西。我的APC安装正确,并显示在phpinfo()就好了。我目前正在apache上运行带有APC 3.1.13的php 5.4.20。这是一个cPanel安装,因此请牢记这一点。PHP的APC缓存不会保留任何变量
主要问题是缓存正在工作,但仅限于页面加载期间。如果我跑
<?php
apc_store('foo', 'bar');
echo apc_fetch('foo');
?>
将回声出变量,但如果我注释掉apc_store并再次运行代码,什么也不显示和显示的var_dump布尔(假);
我试过这段代码,如果我在做一些愚蠢的事情,而且这也不起作用。它总是显示
// Check if str found from cache
if (apc_exists('str')) {
// Print str from cache
echo "str from cache: ", apc_fetch('str'), "<br />";
// Clear cache
apc_clear_cache('user');
// Try to fetch str again
echo "str from cache, after user cache is cleared: ", "<br />";
var_dump(apc_fetch('str'));
}
else {
// Save str to cache and set ttl 120 seconds
echo 'str not found from cache...saving', "<br />";
$str = "This is just test";
apc_store('str', $str, 120);
}
我的APC的配置如下:“STR不是从缓存...节约发现” ......
apc
APC Support => disabled
Version => 3.1.13
APC Debugging => Disabled
MMAP Support => Enabled
MMAP File Mask =>
Locking type => pthread read/write Locks
Serialization Support => broken
Revision => $Revision: 327136 $
Build Date => Oct 17 2013 16:47:57
Directive => Local Value => Master Value
apc.cache_by_default => Off => Off
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.serializer => default => default
apc.shm_segments => 1 => 1
apc.shm_size => 512 => 512
apc.shm_strings_buffer => 4M => 4M
apc.slam_defense => Off => Off
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
我必须失去了一些东西明显.....任何帮助非常感谢。 TIA
编辑
所以我检查,看它是否APC被正确地已APC已经安装了督促服务器上的工作。它实际上是在按照应有的方式工作。所以我运行了php_sapi_name(),在prod服务器上它是apache2handler,在开发服务器上(我正在使用的那个),它使用的是cgi-fcgi,这可能是问题的原因。由于我使用的是cPanel,我应该能够简单地将PHP“Handler”从suPHP更改为DSO,并且在此之后它应该可以工作。 prod服务器不使用cPanel,只是很好的旧时尚....呃.....非cPanel的东西,使其工作。
为什么将它存储在APC中,而不是在会话中 – Machavity
您在PHP中运行什么模式? APC在FastCGI下奇怪地工作,在CGI下根本不工作。 – duskwuff
@Machavity我们已经在会话中存储了一堆东西,我正在查看的数据最适合在中央缓存下使用。 – n0nag0n