Oracle 5.0 Reference Manual page 2679

Table of Contents

Advertisement

Most of the examples use the
extension. However, the plugin can be used with any PHP MySQL extension that is using the
library.
20.7.7.4.1. Architecture and Concepts
Copyright 1997-2012 the PHP Documentation Group. [2230]
The query cache plugin 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
to replace selected mysqlnd C methods. Hereby, it can change the behaviour of any PHP MySQL
extension (mysqli, PDO_MYSQL, mysql) compiled to use the mysqlnd library without changing the
extensions API. This makes the plugin compatible with each and every PHP MySQL application.
Because existing APIs are not changed, it is almost transparent to use. Please, see the
API description
proxy based solutions.
Transparent to use
At PHP run time PECL/mysqlnd_qc can proxy queries send from PHP (mysqlnd) to the MySQL server.
It then inspects the statement string to find whether it shall cache its results. If so, result set is cached
using a storage handler and further executions of the statement are served from the cache for a
user-defined period. The Time to Live (TTL) of the cache entry can either be set globally or on a per
statement basis.
A statement is either cached if the plugin is instructed to cache all statements globally using a or, if the
query string starts with the SQL hint (/*qc=on*/). The plugin is capable of caching any query issued
by calling appropriate API calls of any of the existing PHP MySQL extensions.
Flexible storage: various storage handler
Various storage handler are supported to offer different scopes for cache entries. Different scopes
allow for different degrees in sharing cache entries among clients.
default
deployment model used
• APC: shared memory, scope: single server, multiple web requests
• SQLite: memory or file, scope: single server, multiple web requests
• MEMCACHE: main memory, scope: single or multiple server, multiple web requests
(built-in): user-defined - any, scope: user-defined - any
user
Support for the APC,
and
default
on a per query basis at run time. However, it is recommended to pick one storage handler and use it for
all cache entries.
Built-in slam defense to avoid overloading
To avoid overload situations the cache plugin has a built-in slam defense mechanism. If a popular
cache entries expires many clients using the cache entries will try to refresh the cache entry. For the
duration of the refresh many clients may access the database server concurrently. In the worst case,
the database server becomes overloaded and it takes more and more time to refresh the cache entry,
which in turn lets more and more clients try to refresh the cache entry. To prevent this from happening
the plugin has a slam defense mechanism. If slam defense is enabled and the plugin detects an
expired cache entry it extends the life time of the cache entry before it refreshes the cache entry. This
way other concurrent accesses to the expired cache entry are still served from the cache for a certain
time. The other concurrent accesses to not trigger a concurrent refresh. Ideally, the cache entry gets
Mysqlnd query result cache plugin (mysqlnd_qc)
mysqli
for a discussion of the advantages of the plugin architecture and a comparison with
(built-in): process memory, scope: process, one or more web requests depending on PHP
and
SQLite
handler are built-in. It is possible to switch between compiled-in storage handlers
user
extension because it is the most feature complete PHP MySQL
storage handler has to be enabled at compile time. The
MEMCACHE
2659
mysqlnd
mysqlnd
plugin
mysqlnd plugin

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents