Documentation Home
Connectors and APIs Manual
Download this Manual

Connectors and APIs Manual  /  MySQL and PHP  /  Mysqlnd Memcache plugin

8.11 Mysqlnd Memcache plugin

Copyright 1997-2018 the PHP Documentation Group.

The mysqlnd memcache plugin (mysqlnd_memcache) is an PHP extension for transparently translating SQL into requests for the MySQL InnoDB Memcached Daemon Plugin (server plugin). It includes experimental support for the MySQL Cluster Memcached Daemon. The server plugin provides access to data stored inside MySQL InnoDB (respectively MySQL Cluster NDB) tables using the Memcache protocol. This PHP extension, which supports all PHP MySQL extensions that use mysqlnd, will identify tables exported in this way and will translate specific SELECT queries into Memcache requests.

Figure 8.1 mysqlnd_memcache data flow

The mysqlnd memcache plugin (mysqlnd_memcache), which is a PHP extension, communicates with components of MySQL Server. The MySQL protocol is used to communicate with the SQL engine, and the memcache protocol is used to communicate with the InnoDB memcache daemon. mysqlnd_memcache can use PHP's ext/mysql extension, PHP's MySQLi extension, and PHP Data Objects (PDO).


This plugin depends on the MySQL InnoDB Memcached Daemon Plugin. It is not provided to be used with a stand-alone Memcached. For a generic query cache using Memcached look at the mysqlnd query cache plugin. For direct Memcache access look at the memcache and memcached extensions.

The MySQL native driver for PHP is a C library that ships together with PHP as of PHP 5.3.0. It serves as a drop-in replacement for the MySQL Client Library (libmysqlclient). Using mysqlnd has several advantages: no extra downloads are required because it's bundled with PHP, it's under the PHP license, there is lower memory consumption in certain cases, and it contains new functionality such as asynchronous queries.

The mysqlnd_mmemcache operates, for the most part, transparently from a user perspective. The mysqlnd memcache plugin supports all PHP applications, and all MySQL PHP extensions. It does not change existing APIs. Therefore, it can easily be used with existing PHP applications.

The MySQL Memcache plugins add key-value style access method for data stored in InnoDB resp. NDB (MySQL Cluster) SQL tables through the Memcache protocol. This type of key-value access if often faster than using SQL.