2011-05-27 58 views
7
$bar = 'BAR'; 
apc_store('foo', $bar); 
var_dump(apc_fetch('foo')); 

在一个请求中这个工作。apc_store不在请求之间工作

现在,如果我尝试在它打印另一个请求做var_dump(apc_fetch('foo'));

bool(false) 

任何帮助吗?

我在Gentoo的PHP 5.2,APC-3.1.9

这里什么phpinfo()函数知道APC:

APC Support enabled 
Version 3.1.9 
APC Debugging Disabled 
MMAP Support Enabled 
MMAP File Mask no value 
Locking type pthread mutex Locks 
Serialization Support php 
Revision $Revision: 308812 $ 
Build Date May 27 2011 13:14:20 

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.serializer default default 
apc.shm_segments 1 1 
apc.shm_size 32M 32M 
apc.slam_defense On On 
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 

如果需要其他的相关信息,请告诉我

这里是我如何安装它:https://serverfault.com/questions/274261/failed-installing-apc

我注意到一件事:在phpinfo'配置命令我没有找到apc

'的./configure' '--disable-CLI' ' - 禁用丢弃路径' ' - 禁用力-CGI-重定向' “前缀=的/ usr /本地/ php5' '--with-config-file-path =/usr/local/lib/php5''--with-pear =/usr/share/php5'--enable-exif''--enable- ftp' '--enable-bcmath''--enable-calendar' '--with-gd''--enable-gd-native-ttf' '--with-freetype-dir''--with '--with-imap' '--with-imap-ssl' '--with-png-dir =/usr' '--with-jpeg'--with-zlib-dir''--with-imap' ' -dir =/usr' '--with-xpm-dir =/usr''--with-o penssl' '--with-kerberos''--enable-sysvsem' '--enable-sysvshm''--with-mcrypt' '--with-iconv''--enable-mbstring = all' '--enable-mbregex' '--with-的MySQL =/USR' '--with-mysqli的' '--with卷曲' '--with-XSL'

+0

APC什么版本的? – 2011-05-27 13:03:45

+0

@aj:我下载最新版本:APC-3.1.9 – dynamic 2011-05-27 13:04:23

回答

6

- 见my answer in another question为什么APC不如果PHP通过CGI运行,则工作。

+0

@ yes123:你在使用哪个网络服务器?我使用nginx,因此FastCGI几乎是使用PHP的“常规”方式。如果你使用Apache,你可能会使用mod_php(APC也可以在mod_php上运行)。但我从来没有真正使用Apache,所以我不能告诉你如何配置^^ – NikiC 2011-05-31 18:24:30

0

你的默认TTL( apc.ttl)为0秒,这是奇怪的 - 请保存价值时尝试指定TTL(秒):在php.ini

apc_store('foo', $bar, 60); 
+2

0意味着无限持久性 – dynamic 2011-05-27 14:32:24

0

内容

的apctest2.php

string 'BAR' (length=3) 
apctest2.php

<?php 
var_dump(apc_fetch('foo')); 
?> 

结果的apctest.php

string 'BAR' (length=3) 

含量apctest.php

<?php 
$bar = 'BAR'; 
apc_store('foo', $bar); 
var_dump(apc_fetch('foo')); 
?> 

结果的

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" 

内容

apc。PHP显示 “用户高速缓存条目”

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] 

软件版本下:也许你正在运行PHP在CGI(而不是FastCGI的,你应该使用)

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 
+0

你可以只发布你编辑过的设置吗? – dynamic 2011-05-31 09:22:52

+0

@RR:在我的php.ini中是否正常这些设置不存在?我应该在哪里编辑这个设置? – dynamic 2011-05-31 09:38:55

+0

我只在我的php.ini中拥有它们,而不是在其他地方。顺便说一句,我认为你知道APC刷新保存在Apache重新启动ID,对吧? – RRStoyanov 2011-05-31 09:44:30