1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328862 $ -->
<refentry xml:id="function.mysqlnd-memcache-get-config" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mysqlnd_memcache_get_config</refname>
<refpurpose>Returns information about the plugin configuration</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type>
<methodname>mysqlnd_memcache_get_config</methodname>
<methodparam><type>mixed</type><parameter>connection</parameter></methodparam>
</methodsynopsis>
<para>
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 <function>mysqlnd_memcache_set</function>,
and the table mapping configuration that was automatically collected
from the MySQL Server.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>connection</parameter></term>
<listitem>
<para>
A handle to a MySQL Server using one of the MySQL API extensions for PHP, which are
<link linkend="ref.pdo-mysql">PDO_MYSQL</link>, <link linkend="book.mysqli">mysqli</link> or
<link linkend="book.mysql">ext/mysql</link>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An array of mysqlnd_memcache configuration information on success, otherwise &false;.
</para>
<para>
The returned array has these elements:
</para>
<para>
<table>
<title><function>mysqlnd_memcache_get_config</function> array structure</title>
<tgroup cols="2">
<thead>
<row>
<entry>Array Key</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>memcached</entry>
<entry>
Instance of Memcached associated to this MySQL connection
by <methodname>mysqlnd_memcache_set</methodname>. You can use this to
change settings of the memcache connection, or directly by querying the
server on this connection.
</entry>
</row>
<row>
<entry>pattern</entry>
<entry>
The 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
(<literal>MYSQLND_MEMCACHE_DEFAULT_REGEXP</literal>) or it is set via
<function>mysqlnd_memcache_set</function>.
</entry>
</row>
<row>
<entry>mappings</entry>
<entry>
An 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
<methodname>mysqlnd_memcache_set</methodname>.
</entry>
</row>
<row>
<entry>mapping_query</entry>
<entry>An SQL query used during
<methodname>mysqlnd_memcache_set</methodname>
to identify the available containers and mappings. The result of that
query is provided in the mappings element.
</entry>
</row>
</tbody>
</tgroup>
</table>
<table>
<title>Mapping entry structure</title>
<tgroup cols="2">
<thead>
<row>
<entry>Array Key</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>prefix</entry>
<entry>
A 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.
</entry>
</row>
<row>
<entry>schema_name</entry>
<entry>
Name of the schema (database) which contains the table being accessed.
</entry>
</row>
<row>
<entry>table_name</entry>
<entry>
Name of the table which contains the data accessible via memcache
protocol.
</entry>
</row>
<row>
<entry>id_field_name</entry>
<entry>
Name 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.
</entry>
</row>
<row>
<entry>separator</entry>
<entry>
The 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.
<note>
<para>
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.
</para>
</note>
</entry>
</row>
<row>
<entry>fields</entry>
<entry>
An array with the name of all fields available for this mapping.
</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mysqlnd_memcache_get_config</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("host", "user", "passwd", "database");
$memc = new Memcached();
$memc->addServer("host", 11211);
mysqlnd_memcache_set($mysqli, $memc);
var_dump(mysqlnd_memcache_get_config($mysqli));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(4) {
["memcached"]=>
object(Memcached)#2 (0) {
}
["pattern"]=>
string(125) "/^\s*SELECT\s*(.+?)\s*FROM\s*`?([a-z0-9_]+)`?\s*WHERE\s*`?([a-z0-9_]+)`?\s*=\s*(?(?=["'])["']([^"']*)["']|([0-9e\.]*))\s*$/is"
["mappings"]=>
array(1) {
["mymem_test"]=>
array(6) {
["prefix"]=>
string(13) "@@mymem_test."
["schema_name"]=>
string(4) "test"
["table_name"]=>
string(10) "mymem_test"
["id_field_name"]=>
string(2) "id"
["separator"]=>
string(1) "|"
["fields"]=>
array(3) {
[0]=>
string(2) "f1"
[1]=>
string(2) "f2"
[2]=>
string(2) "f3"
}
}
}
["mapping_query"]=>
string(209) " SELECT c.name,
CONCAT('@@', c.name, (SELECT value FROM innodb_memcache.config_options WHERE name = 'table_map_delimiter')) AS key_prefix,
c.db_schema,
c.db_table,
c.key_columns,
c.value_columns,
(SELECT value FROM innodb_memcache.config_options WHERE name = 'separator') AS sep
FROM innodb_memcache.containers c"
}
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member>
<methodname>mysqlnd_memcache_set</methodname>
</member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|