Documentation Home
Connectors and APIs Manual
Download this Manual

Connectors and APIs Manual  /  ...  /  mysqlnd_memcache_get_config mysqlnd_memcache_get_config

Copyright 1997-2018 the PHP Documentation Group.

  • mysqlnd_memcache_get_config

    Returns information about the plugin configuration


array mysqlnd_memcache_get_config(mixed connection);

This function returns an array of all mysqlnd_memcache related configuration information that is attached to the MySQL connection. This includes MySQL, the Memcache object provided via mysqlnd_memcache_set, and the table mapping configuration that was automatically collected from the MySQL Server.



A handle to a MySQL Server using one of the MySQL API extensions for PHP, which are PDO_MYSQL, mysqli or ext/mysql.

Return Values

An array of mysqlnd_memcache configuration information on success, otherwise FALSE.

The returned array has these elements:

Table 7.43 mysqlnd_memcache_get_config array structure

Array KeyDescription
memcachedInstance of Memcached associated to this MySQL connection by mysqlnd_memcache_set. You can use this to change settings of the memcache connection, or directly by querying the server on this connection.
patternThe PCRE regular expression used to match the SQL query sent to the server. Queries matching this pattern will be further analyzed to decide whether the query can be intercepted and sent via the memcache interface or whether the query is sent using the general MySQL protocol to the server. The pattern is either the default pattern (MYSQLND_MEMCACHE_DEFAULT_REGEXP) or it is set via mysqlnd_memcache_set.
mappingsAn associative array with a list of all configured containers as they were discovered by this plugin. The key for these elements is the name of the container in the MySQL configuration. The value is described below. The contents of this field is created by querying the MySQL Server during association to MySQL and a memcache connection using mysqlnd_memcache_set.
mapping_queryAn SQL query used during mysqlnd_memcache_set to identify the available containers and mappings. The result of that query is provided in the mappings element.

Table 7.44 Mapping entry structure

Array KeyDescription
prefixA prefix used while accessing data via memcache. With the MySQL InnoDB Memcache Deamon plugin, this usually begins with @@ and ends with a configurable separator. This prefix is placed in front of the key value while using the memcache protocol.
schema_nameName of the schema (database) which contains the table being accessed.
table_nameName of the table which contains the data accessible via memcache protocol.
id_field_nameName of the database field (column) with the id used as key when accessing the table via memcache. Often this is the database field having a primary key.
separatorThe separator used to split the different field values. This is needed as memcache only provides access to a single value while MySQL can map multiple columns to this value.

The separator, which can be set in the MySQL Server configuration, should not be part of any value retrieved via memcache because proper mapping can't be guaranteed.

fieldsAn array with the name of all fields available for this mapping.


Example 7.395 mysqlnd_memcache_get_config example

$mysqli = new mysqli("host", "user", "passwd", "database");
$memc = new Memcached();
$memc->addServer("host", 11211);
mysqlnd_memcache_set($mysqli, $memc);

The above example will output:

array(4) {
  object(Memcached)#2 (0) {
  string(125) "/^\s*SELECT\s*(.+?)\s*FROM\s*`?([a-z0-9_]+)`?\s*WHERE\s*`?([a-z0-9_]+)`?\s*=\s*(?(?=["'])["']([^"']*)["']|([0-9e\.]*))\s*$/is"
  array(1) {
    array(6) {
      string(13) "@@mymem_test."
      string(4) "test"
      string(10) "mymem_test"
      string(2) "id"
      string(1) "|"
      array(3) {
        string(2) "f1"
        string(2) "f2"
        string(2) "f3"
  string(209) "    SELECT,
                          CONCAT('@@',, (SELECT value FROM innodb_memcache.config_options WHERE name = 'table_map_delimiter')) AS key_prefix, 
                          (SELECT value FROM innodb_memcache.config_options WHERE name = 'separator') AS sep 
                     FROM innodb_memcache.containers c"

See Also