Mysqlnd Memcache plugin (
mysqlnd_memcache
)
2803
the server to automatically identify exported tables and other configuration options. The results of this
automatic configuration can be retrieved using
mysqlnd_memcache_get_config
.
Parameters
mysql_connection
A handle to a MySQL Server using one of the MySQL API
extensions for PHP, which are
PDO_MYSQL
,
mysqli
or
ext/mysql
.
memcache_connection
A
Memcached
instance with a connection to the MySQL
Memcache Daemon plugin. If this parameter is omitted, then
mysql_connection
will be unassociated from any memcache
connection. And if a previous association exists, then it will be
replaced.
pattern
A regular expression in
Perl Compatible Regular Expression
syntax
used to identify potential Memcache-queries. The query should have
three sub patterns. The first subpattern contains the requested field
list, the second the name of the ID column from the query and the
third the requested value. If this parameter is omitted or os set to
NULL
, then a default pattern will be used.
callback
A callback which will be used whenever a query is being sent to
MySQL. The callback will receive a single boolean parameter telling
if a query was sent via Memcache.
Return Values
TRUE
if the association or disassociation is successful, otherwise
FALSE
if there is an error.
Examples
Example 20.394.
mysqlnd_memcache_set
example with
var_dump
as a simple debugging
callback.
<?php
$mysqli = new mysqli("host", "user", "passwd", "database");
$memc = new Memcached();
$memc->addServer("host", 11211);
mysqlnd_memcache_set($mysqli, $memc, NULL, 'var_dump');
/* This query will be intercepted and executed via Memcache protocol */
echo "Sending query for id via Memcache: ";
$mysqli->query("SELECT f1, f2, f3 FROM test WHERE id = 1");
/* f1 is not configured as valid key field, this won't be sent via Memcache */
echo "Sending query for f1 via Memcache: ";
$mysqli->query("SELECT id FROM test WHERE f1 = 1");
mysqlnd_memcache_set($mysqli);
/* Now the regular MySQL protocol will be used */
echo "var_dump won't be invoked: ";
$mysqli->query("SELECT f1, f2, f3 WHERE id = 1");
?>
The above example will output:
Sending query for id via Memcache: bool(true)
Sending query for f1 via Memcache: bool(false)
var_dump won't be invoked:
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...