Chapter 11 Mysqlnd Memcache plugin (mysqlnd_memcache)

Table of Contents

11.1 Key Features
11.2 Limitations
11.3 On the name
11.4 Quickstart and Examples
11.4.1 Setup
11.4.2 Usage
11.5 Installing/Configuring
11.5.1 Requirements
11.5.2 Installation
11.5.3 Runtime Configuration
11.6 Predefined Constants
11.7 Mysqlnd_memcache Functions
11.7.1 mysqlnd_memcache_get_config
11.7.2 mysqlnd_memcache_set
11.8 Change History
11.8.1 PECL/mysqlnd_memcache 1.0 series

Copyright 1997-2014 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 11.1 mysqlnd_memcache data flow

mysqlnd_memcache data flow


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.