Введение
The mysqlnd query result cache plugin adds easy to use client-side query caching to all PHP MySQL extensions using mysqlnd.
As of version PHP 5.3.3 the MySQL native driver for PHP (
mysqlnd
)
features an internal plugin C API. C plugins, such as the query cache
plugin, can extend the functionality of
mysqlnd.
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 ( mysqli, mysql, PDO_MYSQL). It does not change existing APIs.
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).
Key Features
-
Transparent and therefore easy to use
-
supports all PHP MySQL extensions
-
no API changes
-
very little application changes required
-
-
Flexible invalidation strategy
-
Time-to-Live (TTL)
-
user-defined
-
-
Storage with different scope and life-span
-
Default (Hash, process memory)
-
APC
-
MEMCACHE
-
sqlite
-
user-defined
-
-
Built-in slam defense to prevent cache stampeding.
Limitations
The current 1.0.1 release of PECL mysqlnd_qc does not support PHP 5.4. Version 1.1.0-alpha lifts this limitation.
Prepared statements and unbuffered queries are fully supported.
Thus, the plugin is capable of caching all statements issued
with mysqli
or PDO_MySQL
, which are
the only two PHP MySQL APIs to offer prepared statement support.
On the name
The shortcut mysqlnd_qc
stands for mysqlnd query cache plugin
. The name
was chosen for a quick-and-dirty proof-of-concept. In the beginning
the developers did not expect to continue using the code base.
Sometimes PECL/mysqlnd_qc has also been called
client-side query result set cache
.