Mysqlnd Memcache plugin (
mysqlnd_memcache
)
2797
Example 20.390. Enabling the plugin (php.ini)
; On Windows the filename is php_mysqnd_memcache.dll
; Load the extension
extension=mysqlnd_memcache.so
; Enable it
mysqlnd_memcache.enable=1
Follow the instructions given in the
MySQL Reference Manual on installing the Memcache plugins
for
the MySQL server. Activate the plugins and configure Memcache access for SQL tables.
The examples in this quickguide assume that the following table exists, and that Memcache is
configured with access to it.
Example 20.391. SQL table used for the Quickstart
CREATE TABLE test(
id CHAR(16),
f1 VARCHAR(255),
f2 VARCHAR(255),
f3 VARCHAR(255),
flags INT NOT NULL,
cas_column INT,
expire_time_column INT,
PRIMARY KEY(id)
) ENGINE=InnoDB;
INSERT INTO test (id, f1, f2, f3) VALUES (1, 'Hello', 'World', '!');
INSERT INTO test (id, f1, f2, f3) VALUES (2, 'Lady', 'and', 'the tramp');
INSERT INTO innodb_memcache.containers(
name, db_schema, db_table, key_columns, value_columns,
flags, cas_column, expire_time_column, unique_idx_name_on_key)
VALUES (
'plugin_test', 'test', 'test', 'id', 'f1,f2,f3',
'flags', 'cas_column', 'expire_time_column', 'PRIMARY KEY');
20.7.10.4.2. Usage
Copyright 1997-2012 the PHP Documentation Group. [2230]
After associating a MySQL connection with a Memcache connection using
mysqnd_memcache_set
the plugin attempts to transparently replace SQL
SELECT
statements by a memcache access. For
that purpose the plugin monitors all SQL statements executed and tries to match the statement string
against
MYSQLND_MEMCACHE_DEFAULT_REGEXP
. In case of a match, the mysqlnd memcache plugin
checks whether the
SELECT
is accessing only columns of a mapped table and the
WHERE
clause is
limited to a single key lookup.
In case of the example SQL table, the plugin will use the Memcache interface of the MySQL server to
fetch results for a SQL query like
SELECT f1, f2, f3 WHERE id = n
.
Example 20.392. Basic example.
<?php
$mysqli = new mysqli("host", "user", "passwd", "database");
$memc = new Memcached();
$memc->addServer("host", 11211);
mysqlnd_memcache_set($mysqli, $memc);
/*
This is a query which queries table test using id as key in the WHERE part
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...