php-doc-en/reference/mysqlnd_qc/book.xml

202 lines
5.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Membership: pecl -->
<book xml:id="book.mysqlnd-qc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Mysqlnd query result cache plugin</title>
<titleabbrev>mysqlnd_qc</titleabbrev>
<preface xml:id="intro.mysqlnd-qc">
&reftitle.intro;
<para>
The mysqlnd query result cache plugin adds easy to use client-side query
caching to all PHP MySQL extensions using
<link linkend="book.mysqlnd">mysqlnd</link>.
</para>
<para>
As of version PHP 5.3.3 the MySQL native driver for PHP (
<literal>mysqlnd</literal>)
features an internal plugin C API. C plugins, such as the query cache
plugin, can extend the functionality of
<link linkend="book.mysqlnd">mysqlnd</link>.
</para>
<para>
Mysqlnd plugins such as the query cache plugin operate transparent
from a user perspective. The cache plugin supports all PHP applications
and all PHP MySQL extensions (
<link linkend="ref.mysqli">mysqli</link>,
<link linkend="ref.mysql">mysql</link>,
<link linkend="ref.pdo-mysql">PDO_MYSQL</link>).
It does not change existing APIs.
</para>
<para>
No significant application changes are required to cache a query.
The cache has two operation modes. It will either cache all
queries (not recommended) or only those queries marked with a
certain SQL hint (recommended).
</para>
<section xml:id="mysqlnd-qc.key_features">
<title>Key Features</title>
<para>
<itemizedlist>
<listitem>
<para>
Transparent and therefore easy to use
</para>
<para>
<itemizedlist>
<listitem>
<para>
supports all PHP MySQL extensions
</para>
</listitem>
<listitem>
<para>
no API changes
</para>
</listitem>
<listitem>
<para>
very little application changes required
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
Flexible invalidation strategy
</para>
<para>
<itemizedlist>
<listitem>
<para>
Time-to-Live (TTL)
</para>
</listitem>
<listitem>
<para>
user-defined
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
<listitem>
<para>
Storage with different scope and life-span
</para>
<para>
<itemizedlist>
<listitem>
<para>
Default (Hash, process memory)
</para>
</listitem>
<listitem>
<para>
<link linkend="ref.apc">APC</link>
</para>
</listitem>
<listitem>
<para>
MEMCACHE
</para>
</listitem>
<listitem>
<para>
sqlite
</para>
</listitem>
<listitem>
<para>
user-defined
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
</para>
</section>
<section xml:id="mysqlnd-qc.limitations">
<title>Limitations</title>
<para>
The current 1.0.1 release of PECL mysqlnd_qc does
not support PHP 5.4.
</para>
<para>
Prepared statements and unbuffered queries are fully supported.
Thus, the plugin is capable of caching all statements issued
with <literal>mysqli</literal> or <literal>PDO_MySQL</literal>, which are
the only two PHP MySQL APIs to offer prepared statement support.
</para>
</section>
<section xml:id="mysqlnd-qc.architecture">
<title>Architecture</title>
<para>
The query cache is implemented as a PHP extension.
It is written in C and operates under the hood of PHP. During the
startup of the PHP interpreter it gets registered as a
<link linkend="book.mysqlnd">mysqlnd</link> plugin to replace selected
mysqlnd C methods.
</para>
<para>
At PHP run time it proxies queries send from
mysqlnd (PHP) to the MySQL server. If a query string starts with the SQL hint
(<literal>/*qc=on*/</literal>) to enable caching of it and the query
is not cached (cache miss), the query cache plugin will record the
raw wire protocol data send from MySQL to PHP to answer the query.
The query cache records the wire protocol data in its cache
and replays it, if still valid, on a cache hit.
</para>
<para>
Note that the query cache does not hold decoded result sets consisting
of
<literal>zvals</literal> (C struct representing a PHP variable).
It stores the raw wire data of the MySQL client server protocol.
In case of a cache hits,
<link linkend="book.mysqlnd">mysqlnd</link> still needs
to decode the cached raw wire data into PHP variables before passing
the result to the user space.
This approach has one major advantage: simplicity. Furthermore this
approach eliminates the need for serializing data for cache storage.
</para>
</section>
</preface>
&reference.mysqlnd-qc.setup;
&reference.mysqlnd-qc.constants;
&reference.mysqlnd-qc.usage;
&reference.mysqlnd-qc.reference;
&reference.mysqlnd-qc.changes;
</book>
<!-- 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:"~/.phpdoc/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
-->