Sophie

Sophie

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

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
>Memcache Functions</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="m_verifysslcert"
HREF="function.m-verifysslcert.html"><LINK
REL="NEXT"
TITLE="Memcache::add"
HREF="function.memcache-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.m-verifysslcert.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.memcache-add.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.memcache"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>LXXXVI. Memcache Functions</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN117685"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.intro"
>简介</A
></H1
><P
>&#13;     Memcache module provides handy procedural and object oriented interface
     to memcached, highly effective caching daemon, which was especially
     designed to decrease database load in dynamic web applications.
    </P
><P
>&#13;     More information about memcached can be found at <A
HREF="http://www.danga.com/memcached/"
TARGET="_top"
>http://www.danga.com/memcached/</A
>.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.requirements"
>需求</A
></H1
><P
>&#13;     This module uses functions of <A
HREF="http://www.gzip.org/zlib/"
TARGET="_top"
>zlib</A
>
     to support on-the-fly data compression. Zlib is required to install
     this module.
    </P
><P
>&#13;     PHP 4.3.3 or newer is required to use the memcache extension.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.installation"
>安装</A
></H1
><P
>&#13;  本 <A
HREF="http://pecl.php.net"
TARGET="_top"
>PECL</A
> 扩展未绑定于 PHP 中。
  安装此 PECL 扩展库的信息可在手册中标题为 <A
HREF="install.pecl.html"
>PECL 扩展库安装</A
>的一章中找到。 更多信息如新版本,下载,源文件,维护者信息以及更新日志等可以在这里找到:
  <A
HREF="http://pecl.php.net/package/memcache"
TARGET="_top"
>http://pecl.php.net/package/memcache</A
>.
 </P
><P
>&#13;  In order to use these functions you must compile PHP with Memcache support
  by using the <CODE
CLASS="option"
>--enable-memcache[=DIR]</CODE
> option.
 </P
><P
>&#13;  Windows users will enable <TT
CLASS="filename"
>php_memcache.dll</TT
> inside
  of <TT
CLASS="filename"
>php.ini</TT
> in order to use these functions.
  可以从 <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
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.ini"
>运行时配置</A
></H1
><P
>这些函数的行为受 <TT
CLASS="filename"
>php.ini</TT
> 的影响。</P
><P
>&#13;  <DIV
CLASS="table"
><A
NAME="AEN117716"
></A
><P
><B
>表 1. Memcache Configuration Options</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Default</TH
><TH
>Changeable</TH
><TH
>Changelog</TH
></TR
></THEAD
><TBODY
><TR
><TD
>memcache.allow_failover</TD
><TD
>"1"</TD
><TD
>PHP_INI_ALL</TD
><TD
>Available since Memcache 2.0.2</TD
></TR
><TR
><TD
>memcache.max_failover_attempts</TD
><TD
>"20"</TD
><TD
>PHP_INI_ALL</TD
><TD
>Available since Memcache 2.1.0</TD
></TR
><TR
><TD
>memcache.chunk_size</TD
><TD
>"8192"</TD
><TD
>PHP_INI_ALL</TD
><TD
>Available since Memcache 2.0.2</TD
></TR
><TR
><TD
>memcache.default_port</TD
><TD
>"11211"</TD
><TD
>PHP_INI_ALL</TD
><TD
>Available since Memcache 2.0.2</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.memcache.allow-failover"
></A
><CODE
CLASS="parameter"
>memcache.allow_failover</CODE
>
    <A
HREF="language.types.boolean.html"
><B
CLASS="type"
>boolean</B
></A
></DT
><DD
><P
>&#13;     Whether to transparently failover to other servers on 
     errors.
    </P
></DD
><DT
><A
NAME="ini.memcache.max-failover-attempts"
></A
><CODE
CLASS="parameter"
>memcache.max_failover_attempts</CODE
>
    <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;     Defines how many servers to try when setting and getting data.
     Used only in conjunction with memcache.allow_failover.
    </P
></DD
><DT
><A
NAME="ini.memcache.chunk-size"
></A
><CODE
CLASS="parameter"
>memcache.chunk_size</CODE
>
    <A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
></DT
><DD
><P
>&#13;     Data will be transferred in chunks of this size, setting
     the value lower requires more network writes. Try 
     increasing this value to 32768 if noticing otherwise 
     inexplicable slowdowns.
    </P
></DD
><DT
><A
NAME="ini.memcache.default-port"
></A
><CODE
CLASS="parameter"
>memcache.default_port</CODE
>
    <A
HREF="language.types.string.html"
><B
CLASS="type"
>string</B
></A
></DT
><DD
><P
>&#13;     The default TCP port number to use when connecting to
     the memcached server if no other port is specified.
    </P
></DD
></DL
></DIV
>
</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.resources"
>资源类型</A
></H1
><P
>&#13;     There is only one resource type used in memcache module - it's
     the link identifier for a cache server connection.
    </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.constants"
>预定义常量</A
></H1
><DIV
CLASS="table"
><A
NAME="AEN117779"
></A
><P
><B
>表 2. MemCache Constants</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>&#13;       <TT
CLASS="constant"
><B
>MEMCACHE_COMPRESSED</B
></TT
>
       (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)
      </TD
><TD
>&#13;       Used to turn on-the-fly data compression on with
       <B
CLASS="function"
>Memcache::set()</B
>, 
       <B
CLASS="function"
>Memcache::add()</B
> 和
       <B
CLASS="function"
>Memcache::replace()</B
>.
      </TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="memcache.examples"
>范例</A
></H1
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN117798"
></A
><P
><B
>例 1. memcache extension overview example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$memcache </font><font color="#007700">= new </font><font color="#0000BB">Memcache</font><font color="#007700">;<br /></font><font color="#0000BB">$memcache</font><font color="#007700">-&gt;</font><font color="#0000BB">connect</font><font color="#007700">(</font><font color="#DD0000">'localhost'</font><font color="#007700">, </font><font color="#0000BB">11211</font><font color="#007700">) or die (</font><font color="#DD0000">"Could not connect"</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$version </font><font color="#007700">= </font><font color="#0000BB">$memcache</font><font color="#007700">-&gt;</font><font color="#0000BB">getVersion</font><font color="#007700">();<br />echo </font><font color="#DD0000">"Server's version: "</font><font color="#007700">.</font><font color="#0000BB">$version</font><font color="#007700">.</font><font color="#DD0000">"&lt;br/&gt;\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$tmp_object </font><font color="#007700">= new </font><font color="#0000BB">stdClass</font><font color="#007700">;<br /></font><font color="#0000BB">$tmp_object</font><font color="#007700">-&gt;</font><font color="#0000BB">str_attr </font><font color="#007700">= </font><font color="#DD0000">'test'</font><font color="#007700">;<br /></font><font color="#0000BB">$tmp_object</font><font color="#007700">-&gt;</font><font color="#0000BB">int_attr </font><font color="#007700">= </font><font color="#0000BB">123</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$memcache</font><font color="#007700">-&gt;</font><font color="#0000BB">set</font><font color="#007700">(</font><font color="#DD0000">'key'</font><font color="#007700">, </font><font color="#0000BB">$tmp_object</font><font color="#007700">, </font><font color="#0000BB">false</font><font color="#007700">, </font><font color="#0000BB">10</font><font color="#007700">) or die (</font><font color="#DD0000">"Failed to save data at the server"</font><font color="#007700">);<br />echo </font><font color="#DD0000">"Store data in the cache (data will expire in 10 seconds)&lt;br/&gt;\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$get_result </font><font color="#007700">= </font><font color="#0000BB">$memcache</font><font color="#007700">-&gt;</font><font color="#0000BB">get</font><font color="#007700">(</font><font color="#DD0000">'key'</font><font color="#007700">);<br />echo </font><font color="#DD0000">"Data from the cache:&lt;br/&gt;\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$get_result</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     In the above example, an object is being saved in the cache and then
     retrieved back. Object and other non-scalar types are serialized before 
     saving, so it's impossible to store resources (i.e. connection identifiers
     and others) in the cache.
    </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.memcache-add.html"
>Memcache::add</A
>&nbsp;--&nbsp;Add an item to the server</DT
><DT
><A
HREF="function.memcache-addserver.html"
>Memcache::addServer</A
>&nbsp;--&nbsp;Add a memcached server to connection pool</DT
><DT
><A
HREF="function.memcache-close.html"
>Memcache::close</A
>&nbsp;--&nbsp;Close memcached server connection</DT
><DT
><A
HREF="function.memcache-connect.html"
>Memcache::connect</A
>&nbsp;--&nbsp;Open memcached server connection</DT
><DT
><A
HREF="function.memcache-debug.html"
>memcache_debug</A
>&nbsp;--&nbsp;Turn debug output on/off</DT
><DT
><A
HREF="function.memcache-decrement.html"
>Memcache::decrement</A
>&nbsp;--&nbsp;Decrement item's value</DT
><DT
><A
HREF="function.memcache-delete.html"
>Memcache::delete</A
>&nbsp;--&nbsp;Delete item from the server</DT
><DT
><A
HREF="function.memcache-flush.html"
>Memcache::flush</A
>&nbsp;--&nbsp;Flush all existing items at the server</DT
><DT
><A
HREF="function.memcache-get.html"
>Memcache::get</A
>&nbsp;--&nbsp;Retrieve item from the server</DT
><DT
><A
HREF="function.memcache-getextendedstats.html"
>Memcache::getExtendedStats</A
>&nbsp;--&nbsp;Get statistics from all servers in pool</DT
><DT
><A
HREF="function.memcache-getserverstatus.html"
>Memcache::getServerStatus</A
>&nbsp;--&nbsp;Returns server status</DT
><DT
><A
HREF="function.memcache-getstats.html"
>Memcache::getStats</A
>&nbsp;--&nbsp;Get statistics of the server</DT
><DT
><A
HREF="function.memcache-getversion.html"
>Memcache::getVersion</A
>&nbsp;--&nbsp;Return version of the server</DT
><DT
><A
HREF="function.memcache-increment.html"
>Memcache::increment</A
>&nbsp;--&nbsp;Increment item's value</DT
><DT
><A
HREF="function.memcache-pconnect.html"
>Memcache::pconnect</A
>&nbsp;--&nbsp;Open memcached server persistent connection</DT
><DT
><A
HREF="function.memcache-replace.html"
>Memcache::replace</A
>&nbsp;--&nbsp;Replace value of the existing item</DT
><DT
><A
HREF="function.memcache-set.html"
>Memcache::set</A
>&nbsp;--&nbsp;Store data at the server</DT
><DT
><A
HREF="function.memcache-setcompressthreshold.html"
>Memcache::setCompressThreshold</A
>&nbsp;--&nbsp;Enable automatic compression of large values</DT
><DT
><A
HREF="function.memcache-setserverparams.html"
>Memcache::setServerParams</A
>&nbsp;--&nbsp;Changes server parameters and status at runtime</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.m-verifysslcert.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.memcache-add.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>m_verifysslcert</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Memcache::add</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>