mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added documentation for new methods in memcache release 2.0.0
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@203564 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
902abed4f9
commit
6b94e5d145
5 changed files with 285 additions and 7 deletions
102
reference/memcache/functions/memcache-addserver.xml
Normal file
102
reference/memcache/functions/memcache-addserver.xml
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id="function.Memcache-addServer">
|
||||
<refnamediv>
|
||||
<refname>Memcache::addServer</refname>
|
||||
<refpurpose>Add a memcached server to connection pool</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>Memcache::addServer</methodname>
|
||||
<methodparam><type>string</type><parameter>host</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>port</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>bool</type><parameter>persistent</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>weight</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>timeout</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>retry_interval</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>Memcache::addServer</function> adds a server to the connection
|
||||
pool. The actual connection is established on first use.
|
||||
Parameters <parameter>host</parameter> and <parameter>port</parameter> point
|
||||
to the host and port, where memcached is listening for connections.
|
||||
Parameter <parameter>port</parameter> is optional, it's default value is
|
||||
11211.
|
||||
Parameter <parameter>persistent</parameter> controls the use of a persistent
|
||||
connection, the default is &true;.
|
||||
Parameter <parameter>weight</parameter> is the number of buckets to create for this
|
||||
server which in turn control its probability of it being selected. The probability is
|
||||
relative to the total weight of all servers.
|
||||
You can define a <parameter>timeout</parameter> (in seconds), which will be
|
||||
used when connecting to the daemon. Think twice before changing the default
|
||||
value of 1 second - you can loose all the advantages of caching if your connection
|
||||
is too slow.
|
||||
Parameter <parameter>retry_interval</parameter> controls how often a failed server
|
||||
will be retried, the default value is 15 seconds. Neither this nor the
|
||||
<parameter>persistent</parameter> parameter has any effect when this extension
|
||||
is loaded dynamically via <function>dl</function>.
|
||||
</para>
|
||||
<para>
|
||||
The connection, which was opened using
|
||||
<function>Memcache::addServer</function> will be automatically closed at the
|
||||
end of script execution. Also you can close it with
|
||||
<function>Memcache::close</function>.
|
||||
</para>
|
||||
<para>
|
||||
You can also use the <function>memcache_add_server</function> function.
|
||||
See example below.
|
||||
</para>
|
||||
<example>
|
||||
<title><function>Memcache::addServer</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
/* OO API */
|
||||
|
||||
$memcache = new Memcache;
|
||||
$memcache->addServer('memcache_host', 11211);
|
||||
$memcache->addServer('memcache_host2', 11211);
|
||||
|
||||
/* procedural API */
|
||||
|
||||
$memcache_obj = memcache_connect('memcache_host', 11211);
|
||||
memcache_add_server($memcache_obj, 'memcache_host2', 11211);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
&return.success;
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<function>Memcache::connect</function>,
|
||||
<function>Memcache::pconnect</function> and
|
||||
<function>Memcache::close</function> and
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
106
reference/memcache/functions/memcache-getextendedstats.xml
Normal file
106
reference/memcache/functions/memcache-getextendedstats.xml
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id="function.Memcache-getExtendedStats">
|
||||
<refnamediv>
|
||||
<refname>Memcache::getExtendedStats</refname>
|
||||
<refpurpose>Get statistics from all servers in pool</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>Memcache::getExtendedStats</methodname>
|
||||
<void/>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>Memcache::getExtendedStats</function> returns an two-dimensional
|
||||
associative array with server statistics. Array keys correspond to
|
||||
host:port of server and values contain the individual server statistics.
|
||||
A failed server will have its corresponding entry set to &false;.
|
||||
</para>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<pre>
|
||||
<?php
|
||||
$memcache_obj = new Memcache;
|
||||
$memcache_obj->addServer('memcache_host', 11211);
|
||||
$memcache_obj->addServer('failed_host', 11211);
|
||||
|
||||
$stats = $memcache_obj->getExtendedStats();
|
||||
print_r($stats);
|
||||
?>
|
||||
</pre>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<pre>
|
||||
Array
|
||||
(
|
||||
[memcache_host:11211] => Array
|
||||
(
|
||||
[pid] => 3756
|
||||
[uptime] => 603011
|
||||
[time] => 1133810435
|
||||
[version] => 1.1.12
|
||||
[rusage_user] => 0.451931
|
||||
[rusage_system] => 0.634903
|
||||
[curr_items] => 2483
|
||||
[total_items] => 3079
|
||||
[bytes] => 2718136
|
||||
[curr_connections] => 2
|
||||
[total_connections] => 807
|
||||
[connection_structures] => 13
|
||||
[cmd_get] => 9748
|
||||
[cmd_set] => 3096
|
||||
[get_hits] => 5976
|
||||
[get_misses] => 3772
|
||||
[bytes_read] => 3448968
|
||||
[bytes_written] => 2318883
|
||||
[limit_maxbytes] => 33554432
|
||||
)
|
||||
|
||||
[failed_host:11211] => false
|
||||
)
|
||||
</pre>
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
You can also use the <function>memcache_get_extended_stats</function> function.
|
||||
</para>
|
||||
<para>
|
||||
<function>Memcache::getExtendedStats</function> returns &false; in case of an
|
||||
error.
|
||||
</para>
|
||||
<para>
|
||||
See also
|
||||
<function>Memcache::getVersion</function>.
|
||||
<function>Memcache::getStats</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.Memcache-getStats">
|
||||
<refnamediv>
|
||||
<refname>Memcache::getStats</refname>
|
||||
|
@ -26,6 +26,7 @@
|
|||
<para>
|
||||
See also
|
||||
<function>Memcache::getVersion</function>.
|
||||
<function>Memcache::getExtendedStats</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id="function.Memcache-setCompressThreshold">
|
||||
<refnamediv>
|
||||
<refname>Memcache::setCompressThreshold</refname>
|
||||
<refpurpose>Enable automatic compression of large values</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>Memcache::setCompressThreshold</methodname>
|
||||
<methodparam><type>int</type><parameter>threshold</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>float</type><parameter>min_savings</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>Memcache::setCompressThreshold</function> enables automatic
|
||||
compression of large values. Parameter <parameter>threshold</parameter>
|
||||
controls the minimum value length before attempting to compress automatically.
|
||||
Parameter <parameter>min_savings</parameter> specifies the minimum amount
|
||||
of savings to actually store the value compressed. The supplied value
|
||||
must be between 0 and 1. Default value is 0.2 giving a minimum 20%
|
||||
compression savings.
|
||||
</para>
|
||||
<para>
|
||||
You can also use the <function>memcache_set_compress_threshold</function> function.
|
||||
See example below.
|
||||
</para>
|
||||
<example>
|
||||
<title><function>Memcache::setCompressThreshold</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
/* OO API */
|
||||
|
||||
$memcache_obj = new Memcache;
|
||||
$memcache_obj->addServer('memcache_host', 11211);
|
||||
$memcache_obj->setCompressThreshold(20000, 0.2);
|
||||
|
||||
/* procedural API */
|
||||
|
||||
$memcache_obj = memcache_connect('memcache_host', 11211);
|
||||
memcache_set_compress_threshold($memcache_obj, 20000, 0.2);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
&return.success;
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- Purpose: remote.other -->
|
||||
<!-- Membership: pecl, external -->
|
||||
|
||||
|
@ -15,11 +15,6 @@
|
|||
to memcached, highly effective caching daemon, which was especially
|
||||
designed to decrease database load in dynamic web applications.
|
||||
</para>
|
||||
<para>
|
||||
This module doesn't have native support of multiple servers, but you
|
||||
still can implement it yourself in your application. Establish several
|
||||
memcached connections, set priority level for each server etc.
|
||||
</para>
|
||||
<para>
|
||||
More information about memcached can be found at <ulink
|
||||
url="&url.memcache;">&url.memcache;</ulink>.
|
||||
|
|
Loading…
Reference in a new issue