Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 10815

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>APC 可选 PHP 缓存</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="virtual"
HREF="function.virtual.html"><LINK
REL="NEXT"
TITLE="apc_add"
HREF="function.apc-add.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="reference"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.virtual.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.apc-add.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.apc"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>III. APC 可选 PHP 缓存</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN8952"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="apc.intro"
>简介</A
></H1
><P
>&#13;    Alternative PHP Cache(APC)是 PHP 的一个免费公开的优化代码缓存。它用来提供免费,公开并且强健的架构来缓存和优化
    PHP 的中间代码。
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="apc.installation"
>安装</A
></H1
><P
>&#13;    本 <A
HREF="http://pecl.php.net"
TARGET="_top"
>PECL</A
> 扩展未绑定于 PHP 中。
   </P
><P
>&#13;    安装此 PECL 扩展库的信息可在手册中标题为 <A
HREF="install.pecl.html"
>PECL 扩展库安装</A
>的一章中找到。 更多信息如新版本,下载,源文件,维护者信息以及更新日志等可以在这里找到:<A
HREF="http://pecl.php.net/package/apc"
TARGET="_top"
>http://pecl.php.net/package/apc</A
>。
   </P
><P
>&#13;    可以从 <A
HREF="http://www.php.net/downloads.php"
TARGET="_top"
>PHP
下载页面</A
>或者 <A
HREF="http://snaps.php.net/"
TARGET="_top"
>http://snaps.php.net/</A
>
下载此 <ACRONYM
CLASS="acronym"
>PECL</ACRONYM
> 扩展的
<ACRONYM
CLASS="acronym"
>DLL</ACRONYM
> 文件。
   </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
     在 Windows 下,APC 要求有 <TT
CLASS="literal"
>c:\tmp</TT
> 目录,并且该目录要对 Web
     服务器进程可写。
    </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
     更多深入且高度专业的文档,见开发者提供的 <A
HREF="http://cvs.php.net/viewvc.cgi/pecl/apc/TECHNOTES.txt?view=co"
TARGET="_top"
>TECHNOTES</A
> 文件。
    </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="apc.configuration"
>运行时配置</A
></H1
><P
>这些函数的行为受 <TT
CLASS="filename"
>php.ini</TT
> 的影响。</P
><P
>&#13;  尽管默认的 APC 设定对于大多数安装已经没问题,但专业人员应考虑调整以下参数。
 </P
><P
>&#13;  <DIV
CLASS="table"
><A
NAME="AEN8980"
></A
><P
><B
>表 1. APC configuration options</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>名称</TH
><TH
>默认值</TH
><TH
>可修改范围</TH
><TH
>更新记录</TH
></TR
></THEAD
><TBODY
><TR
><TD
>apc.enabled</TD
><TD
>"1"</TD
><TD
>PHP_INI_ALL</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.shm_segments</TD
><TD
>"1"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.shm_size</TD
><TD
>"30"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.optimization</TD
><TD
>"0"</TD
><TD
>PHP_INI_ALL</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.num_files_hint</TD
><TD
>"1000"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.ttl</TD
><TD
>"0"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.gc_ttl</TD
><TD
>"3600"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.cache_by_default</TD
><TD
>"1"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.filters</TD
><TD
>NULL</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.mmap_file_mask</TD
><TD
>NULL</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.slam_defense</TD
><TD
>"0"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.file_update_protection</TD
><TD
>"2"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>apc.enable_cli</TD
><TD
>"0"</TD
><TD
>PHP_INI_SYSTEM</TD
><TD
>&#62; APC 3.0.6</TD
></TR
></TBODY
></TABLE
></DIV
>
  有关 PHP_INI_* 常量进一步的细节与定义参见<A
HREF="ini.html"
>附录 H</A
>。
 </P
><P
>以下是配置选项的简要解释。</P
><P
>&#13;  <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><A
NAME="ini.apc.enabled"
></A
><CODE
CLASS="parameter"
>apc.enabled</CODE
>
     <A
HREF="language.types.boolean.html"
><B
CLASS="type"
>boolean</B
></A
></DT
><DD
><P
>&#13;      <TT
CLASS="literal"
>apc.enabled</TT
> 可以设成 0 来禁用 APC。这主要是用在当
      APC 被静态编译入 PHP 时,因为没有其它方法来禁用了(编译为
      DSO 的时候,可以将 <TT
CLASS="literal"
>php.ini</TT
> 中的
      <TT
CLASS="literal"
>extension</TT
> 行注释掉)。
     </P
></DD
><DT
><A
NAME="ini.apc.shm-segments"
></A
><CODE
CLASS="parameter"
>apc.shm_segments</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      对编译器缓存要分配的共享内存块的数目。如果 APC 用光了共享内存但是已经将
      <TT
CLASS="literal"
>apc.shm_size</TT
> 设为了系统所能允许的最大值,可以尝试增大此值。
     </P
></DD
><DT
><A
NAME="ini.apc.shm-size"
></A
><CODE
CLASS="parameter"
>apc.shm_size</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      以 MB 为单位的每个共享内存块的大小。默认时,有些系统(包括大多数
      BSD 变种)的共享内存块大小非常低。
     </P
></DD
><DT
><A
NAME="ini.apc.optimization"
></A
><CODE
CLASS="parameter"
>apc.optimization</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      优化级别。设为 0 则禁用优化器,更高的值则使用更主动的优化。期望非常有限的速度提升。尚在试验中。
     </P
></DD
><DT
><A
NAME="ini.apc.num-files-hint"
></A
><CODE
CLASS="parameter"
>apc.num_files_hint</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      Web 服务器上的被包含或被请求的不同源文件的数目的大概估计。如果不确定则设为
      0 或去掉此项;此设定主要用在有数千个源文件的站点。
     </P
></DD
><DT
><A
NAME="ini.apc.ttl"
></A
><CODE
CLASS="parameter"
>apc.ttl</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      缓存条目在缓冲区所允许的空闲时间的秒数。将此设为零意味着缓冲区有可能被阻赛了的缓存充满而导致新条目不被缓存。
     </P
></DD
><DT
><A
NAME="ini.apc.gc-ttl"
></A
><CODE
CLASS="parameter"
>apc.gc_ttl</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      缓存条目在垃圾回收表中能够存在的秒数。此值提供了一个安全措施,即在服务器进程在执行缓存的源文件时,如果该文件被修改则旧版本将不会被回收,直到达到此
      TTL 为止。设为零将禁用此特性。
     </P
></DD
><DT
><A
NAME="ini.apc.cache-by-default"
></A
><CODE
CLASS="parameter"
>apc.cache_by_default</CODE
>
     <A
HREF="language.types.boolean.html"
><B
CLASS="type"
>boolean</B
></A
></DT
><DD
><P
>&#13;      默认为 on,但可以设为 off 并和加号开头的
      <TT
CLASS="literal"
>apc.filters</TT
> 一起用,则文件仅在匹配过滤器时被缓存。
     </P
></DD
><DT
><A
NAME="ini.apc.filters"
></A
><CODE
CLASS="parameter"
>apc.filters</CODE
>
     <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
></DT
><DD
><P
>&#13;      一个以逗号分隔的 POSIX
      扩展正则表达式的列表。如果任一个模式匹配源文件名,则该文件不被缓存。注意用来匹配的文件名是传递给
      include/require 的文件名,而不是绝对路径。如果正则表达式的第一个字符是
      <TT
CLASS="literal"
>+</TT
> 则意味着任何匹配表达式的文件会被缓存,如果第一个字符是
      <TT
CLASS="literal"
>-</TT
> 则任何匹配项都不会被缓存。<TT
CLASS="literal"
>-</TT
>
      是默认值,可以省略掉。
     </P
></DD
><DT
><A
NAME="ini.apc.mmap-file-mask"
></A
><CODE
CLASS="parameter"
>apc.mmap_file_mask</CODE
>
     <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
></DT
><DD
><P
>&#13;      If compiled with MMAP support by using <TT
CLASS="literal"
>--enable-mmap</TT
>
      this is the mktemp-style file_mask to pass to the
      mmap module for determing whether your mmap'ed memory
      region is going to be file-backed or shared memory
      backed.  For straight file-backed mmap, set it to
      something like <TT
CLASS="literal"
>/tmp/apc.XXXXXX</TT
>
      (exactly 6 <TT
CLASS="literal"
>X</TT
>s).
      To use POSIX-style shm_open/mmap put a <TT
CLASS="literal"
>.shm</TT
>
      somewhere in your mask.  e.g. <TT
CLASS="literal"
>/apc.shm.XXXXXX</TT
>
      You can also set it to <TT
CLASS="literal"
>/dev/zero</TT
> to use your
      kernel's <TT
CLASS="literal"
>/dev/zero</TT
> interface to anonymous mmap'ed
      memory.  Leaving it undefined will force an anonymous mmap.
     </P
></DD
><DT
><A
NAME="ini.apc.slam-defense"
></A
><CODE
CLASS="parameter"
>apc.slam_defense</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      On very busy servers whenever you start the server or
      modify files you can create a race of many processes
      all trying to cache the same file at the same time.
      This option sets the percentage of processes that will
      skip trying to cache an uncached file.  Or think of it
      as the probability of a single process to skip caching.
      For example, setting <TT
CLASS="literal"
>apc.slam_defense</TT
>
      to <TT
CLASS="literal"
>75</TT
> would mean that there is
      a 75% chance that the process will not cache an uncached
      file. So, the higher the setting the greater the defense
      against cache slams.  Setting this to <TT
CLASS="literal"
>0</TT
>
      disables this feature.
     </P
></DD
><DT
><A
NAME="ini.apc.file-update-protection"
></A
><CODE
CLASS="parameter"
>apc.file_update_protection</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      When you modify a file on a live web server you really
      should do so in an atomic manner.  That is, write to a
      temporary file and rename (<TT
CLASS="literal"
>mv</TT
>) the file into its
      permanent position when it is ready.  Many text editors, cp, tar and
      other such programs don't do this.  This means that there
      is a chance that a file is accessed (and cached) while it
      is still being written to.  This <TT
CLASS="literal"
>apc.file_update_protection</TT
>
      setting puts a delay on caching brand new files.  The
      default is 2 seconds which means that if the modification
      timestamp (<TT
CLASS="literal"
>mtime</TT
>) on a file shows that it is less than 2
      seconds old when it is accessed, it will not be cached.
      The unfortunate person who accessed this half-written file
      will still see weirdness, but at least it won't persist.
      If you are certain you always atomically update your files
      by using something like rsync which does this correctly, you
      can turn this protection off by setting it to 0.  If you
      have a system that is flooded with io causing some update
      procedure to take longer than 2 seconds, you may want to
      increase this a bit.
     </P
></DD
><DT
><A
NAME="ini.apc.enable-cli"
></A
><CODE
CLASS="parameter"
>apc.enable_cli</CODE
>
     <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;      Mostly for testing and debugging.  Setting this enables APC
      for the CLI version of PHP.  Normally you wouldn't want to
      create, populate and tear down the APC cache on every CLI
      request, but for various test scenarios it is handy to be
      able to enable APC for the CLI version of APC easily.
     </P
></DD
></DL
></DIV
>
 </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="apc.resources"
>资源类型</A
></H1
><P
>本扩展模块未定义任何资源类型。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="apc.constants"
>预定义常量</A
></H1
><P
>本扩展模块未定义任何常量。</P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.apc-add.html"
>apc_add</A
>&nbsp;--&nbsp;
   Cache a variable in the data store (only if it's not stored)
  </DT
><DT
><A
HREF="function.apc-cache-info.html"
>apc_cache_info</A
>&nbsp;--&nbsp;
   Retrieves cached information (and meta-data) from APC's data store
  </DT
><DT
><A
HREF="function.apc-clear-cache.html"
>apc_clear_cache</A
>&nbsp;--&nbsp;
   Clears the APC cache 
  </DT
><DT
><A
HREF="function.apc-define-constants.html"
>apc_define_constants</A
>&nbsp;--&nbsp;
   Defines a set of constants for retrieval and mass-definition 
  </DT
><DT
><A
HREF="function.apc-delete.html"
>apc_delete</A
>&nbsp;--&nbsp;
   Removes a stored variable from the cache 
  </DT
><DT
><A
HREF="function.apc-fetch.html"
>apc_fetch</A
>&nbsp;--&nbsp;
   Fetch a stored variable from the cache 
  </DT
><DT
><A
HREF="function.apc-load-constants.html"
>apc_load_constants</A
>&nbsp;--&nbsp;
   Loads a set of constants from the cache
  </DT
><DT
><A
HREF="function.apc-sma-info.html"
>apc_sma_info</A
>&nbsp;--&nbsp;
   Retrieves APC's Shared Memory Allocation information 
  </DT
><DT
><A
HREF="function.apc-store.html"
>apc_store</A
>&nbsp;--&nbsp;
   Cache a variable in the data store 
  </DT
></DL
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.virtual.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.apc-add.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>virtual</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>apc_add</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>