mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
590 lines
19 KiB
HTML
590 lines
19 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Returns information on the current handler, the number of cache entries and cache entries, if available</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mysqlnd-qc-get-cache-info" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mysqlnd_qc_get_cache_info</h1>
|
|
<p class="verinfo">(PECL mysqlnd_qc >= 1.0.0)</p><p class="refpurpose"><span class="refname">mysqlnd_qc_get_cache_info</span> — <span class="dc-title">Returns information on the current handler, the number of cache entries and cache entries, if available</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mysqlnd-qc-get-cache-info-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
|
|
<span class="methodname"><strong>mysqlnd_qc_get_cache_info</strong></span>
|
|
( <span class="methodparam">void</span>
|
|
) : <span class="type">array</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mysqlnd-qc-get-cache-info-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">此函数没有参数。</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-qc-get-cache-info-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns information on the current handler, the number of cache entries and
|
|
cache entries, if available. If and what data will be returned for the cache
|
|
entries is subject to the active storage handler.
|
|
Storage handler are free to return any data. Storage handler are
|
|
recommended to return at least the data provided by the default handler,
|
|
if technically possible.
|
|
</p>
|
|
<p class="para">
|
|
The scope of the information is the PHP process. Depending on the PHP deployment
|
|
model a process may serve one or more web requests.
|
|
</p>
|
|
<p class="para">
|
|
Values are aggregated for all cache activities on a per storage handler basis.
|
|
It is not possible to tell how much queries originating from
|
|
<em>mysqli</em>, <em>PDO_MySQL</em> or
|
|
<em>mysql</em>.API calls have contributed to the aggregated data values. Use
|
|
<span class="function"><a href="mysqlnd_qc_get_core_stats.html" class="function">mysqlnd_qc_get_core_stats()</a></span>
|
|
to get timing data aggregated for all storage handlers.
|
|
</p>
|
|
<p class="para">
|
|
Array of cache information
|
|
</p>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">handler</code>
|
|
<span class="type"><a href="language.types.string.html" class="type string">string</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The active storage handler.
|
|
</p>
|
|
<p class="para">
|
|
All storage handler. Since 1.0.0.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">handler_version</code>
|
|
<span class="type"><a href="language.types.string.html" class="type string">string</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The version of the active storage handler.
|
|
</p>
|
|
<p class="para">
|
|
All storage handler. Since 1.0.0.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">num_entries</code>
|
|
<span class="type"><a href="language.types.integer.html" class="type int">int</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The number of cache entries. The value depends on the storage handler in use.
|
|
</p>
|
|
<p class="para">
|
|
The default, APC and SQLite storage handler provide the actual
|
|
number of cache entries.
|
|
</p>
|
|
<p class="para">
|
|
The MEMCACHE storage handler always returns <em>0</em>.
|
|
MEMCACHE does not support counting the number of cache entries.
|
|
</p>
|
|
<p class="para">
|
|
If a user defined handler is used, the number of
|
|
entries of the <em>data</em> property is reported.
|
|
</p>
|
|
<p class="para">
|
|
Since 1.0.0.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">data</code>
|
|
<span class="type"><a href="language.types.array.html" class="type array">array</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The version of the active storage handler.
|
|
</p>
|
|
<p class="para">
|
|
Additional storage handler dependent data on the cache entries.
|
|
Storage handler are requested to provide similar and comparable
|
|
information. A user defined storage handler is free to return any data.
|
|
</p>
|
|
<p class="para">
|
|
Since 1.0.0.
|
|
</p>
|
|
<p class="para">
|
|
The following information is provided by the default storage handler
|
|
for the <em>data</em> property.
|
|
</p>
|
|
<p class="para">
|
|
The <em>data</em>
|
|
property holds a hash. The hash is indexed by the internal
|
|
cache entry identifier of the storage handler. The cache entry identifier
|
|
is human-readable and contains the query string leading to the cache entry.
|
|
Please, see also the example below. The following data is given for
|
|
every cache entry.
|
|
</p>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">statistics</code>
|
|
<span class="type"><a href="language.types.array.html" class="type array">array</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Statistics of the cache entry.
|
|
</p>
|
|
<p class="para">
|
|
Since 1.0.0.
|
|
</p>
|
|
<table class="doctable informaltable">
|
|
|
|
<col width="1*" />
|
|
<col width="7*" />
|
|
<col width="2*" />
|
|
<thead>
|
|
<tr>
|
|
<th>Property</th>
|
|
<th>Description</th>
|
|
<th>Version</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td>
|
|
<em>rows</em>
|
|
</td>
|
|
<td>
|
|
Number of rows of the cached result set.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>stored_size</em>
|
|
</td>
|
|
<td>
|
|
The size of the cached result set in bytes. This is the size
|
|
of the payload. The value is not suited for calculating the
|
|
total memory consumption of all cache entries including the
|
|
administrative overhead of the cache entries.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>cache_hits</em>
|
|
</td>
|
|
<td>
|
|
How often the cached entry has been returned.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>run_time</em>
|
|
</td>
|
|
<td>
|
|
Run time of the statement to which the cache entry belongs.
|
|
This is the run time of the uncached statement. It is the time
|
|
between sending the statement to MySQL receiving a reply from MySQL.
|
|
Run time saved by using the query cache plugin can be calculated
|
|
like this: <em>cache_hits * ((run_time - avg_run_time) + (store_time - avg_store_time))</em>.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>store_time</em>
|
|
</td>
|
|
<td>
|
|
Store time of the statements result set to which the cache entry belongs.
|
|
This is the time it took to fetch and store the results of the uncached
|
|
statement.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>min_run_time</em>
|
|
</td>
|
|
<td>
|
|
Minimum run time of the cached statement. How long it took
|
|
to find the statement in the cache.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>min_store_time</em>
|
|
</td>
|
|
<td>
|
|
Minimum store time of the cached statement. The time taken
|
|
for fetching the cached result set from the storage medium and
|
|
decoding
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>avg_run_time</em>
|
|
</td>
|
|
<td>
|
|
Average run time of the cached statement.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>avg_store_time</em>
|
|
</td>
|
|
<td>
|
|
Average store time of the cached statement.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>max_run_time</em>
|
|
</td>
|
|
<td>
|
|
Average run time of the cached statement.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>max_store_time</em>
|
|
</td>
|
|
<td>
|
|
Average store time of the cached statement.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>valid_until</em>
|
|
</td>
|
|
<td>
|
|
Timestamp when the cache entry expires.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
|
|
<code class="parameter">metadata</code>
|
|
<span class="type"><a href="language.types.array.html" class="type array">array</a></span>
|
|
</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Metadata of the cache entry.
|
|
This is the metadata provided by MySQL together with the
|
|
result set of the statement in question. Different versions
|
|
of the MySQL server may return different metadata. Unlike with
|
|
some of the PHP MySQL extensions no attempt is made to hide
|
|
MySQL server version dependencies and version details from the
|
|
caller. Please, refer to the MySQL C API documentation that
|
|
belongs to the MySQL server in use for further details.
|
|
</p>
|
|
<p class="para">
|
|
The metadata list contains one entry for every column.
|
|
</p>
|
|
<p class="para">
|
|
Since 1.0.0.
|
|
</p>
|
|
<table class="doctable informaltable">
|
|
|
|
<col width="1*" />
|
|
<col width="7*" />
|
|
<col width="2*" />
|
|
<thead>
|
|
<tr>
|
|
<th>Property</th>
|
|
<th>Description</th>
|
|
<th>Version</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td>
|
|
<em>name</em>
|
|
</td>
|
|
<td>
|
|
The field name. Depending on the MySQL version this
|
|
may be the fields alias name.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>org_name</em>
|
|
</td>
|
|
<td>
|
|
The field name.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>table</em>
|
|
</td>
|
|
<td>
|
|
The table name. If an alias name was used for the table, this
|
|
usually holds the alias name.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>org_table</em>
|
|
</td>
|
|
<td>
|
|
The table name.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>db</em>
|
|
</td>
|
|
<td>
|
|
The database/schema name.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>max_length</em>
|
|
</td>
|
|
<td>
|
|
The maximum width of the field. Details may vary by MySQL server version.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>length</em>
|
|
</td>
|
|
<td>
|
|
The width of the field. Details may vary by MySQL server version.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>type</em>
|
|
</td>
|
|
<td>
|
|
The data type of the field. Details may vary by the MySQL server in use.
|
|
This is the MySQL C API type constants value. It is recommended
|
|
to use type constants provided by the <em>mysqli</em> extension
|
|
to test for its meaning. You should not test for certain type values
|
|
by comparing with certain numbers.
|
|
</td>
|
|
<td>Since 1.0.0.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
<p class="para">
|
|
The APC storage handler returns the same information
|
|
for the <em>data</em> property but no <em>metadata</em>.
|
|
The <em>metadata</em> of a cache entry is set to <em>NULL</em>.
|
|
</p>
|
|
<p class="para">
|
|
The MEMCACHE storage handler does not fill the <em>data</em> property.
|
|
Statistics are not available on a per cache entry basis with the MEMCACHE storage
|
|
handler.
|
|
</p>
|
|
<p class="para">
|
|
A user defined storage handler is free to provide any data.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mysqlnd-qc-get-cache-info-examples">
|
|
<h3 class="title">范例</h3>
|
|
<div class="example" id="example-2295">
|
|
<p><strong>Example #1 <span class="function"><strong>mysqlnd_qc_get_cache_info()</strong></span> example</strong></p>
|
|
<div class="example-contents"><p>
|
|
The example shows the output from the built-in default storage handler.
|
|
Other storage handler may report different data.
|
|
</p></div>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* Populate the cache, e.g. using mysqli */<br /></span><span style="color: #0000BB">$mysqli </span><span style="color: #007700">= new </span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"host"</span><span style="color: #007700">, </span><span style="color: #DD0000">"user"</span><span style="color: #007700">, </span><span style="color: #DD0000">"password"</span><span style="color: #007700">, </span><span style="color: #DD0000">"schema"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-></span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"/*" </span><span style="color: #007700">. </span><span style="color: #0000BB">MYSQLND_QC_ENABLE_SWITCH </span><span style="color: #007700">. </span><span style="color: #DD0000">"*/SELECT id FROM test"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Display cache information */<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_qc_get_cache_info</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
array(4) {
|
|
["num_entries"]=>
|
|
int(1)
|
|
["handler"]=>
|
|
string(7) "default"
|
|
["handler_version"]=>
|
|
string(5) "1.0.0"
|
|
["data"]=>
|
|
array(1) {
|
|
["Localhost via UNIX socket 3306 user schema|/*qc=on*/SELECT id FROM test"]=>
|
|
array(2) {
|
|
["statistics"]=>
|
|
array(11) {
|
|
["rows"]=>
|
|
int(6)
|
|
["stored_size"]=>
|
|
int(101)
|
|
["cache_hits"]=>
|
|
int(0)
|
|
["run_time"]=>
|
|
int(471)
|
|
["store_time"]=>
|
|
int(27)
|
|
["min_run_time"]=>
|
|
int(0)
|
|
["max_run_time"]=>
|
|
int(0)
|
|
["min_store_time"]=>
|
|
int(0)
|
|
["max_store_time"]=>
|
|
int(0)
|
|
["avg_run_time"]=>
|
|
int(0)
|
|
["avg_store_time"]=>
|
|
int(0)
|
|
}
|
|
["metadata"]=>
|
|
array(1) {
|
|
[0]=>
|
|
array(8) {
|
|
["name"]=>
|
|
string(2) "id"
|
|
["orig_name"]=>
|
|
string(2) "id"
|
|
["table"]=>
|
|
string(4) "test"
|
|
["orig_table"]=>
|
|
string(4) "test"
|
|
["db"]=>
|
|
string(4) "schema"
|
|
["max_length"]=>
|
|
int(1)
|
|
["length"]=>
|
|
int(11)
|
|
["type"]=>
|
|
int(3)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.mysqlnd-qc-get-cache-info-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member">
|
|
<span class="function"><a href="mysqlnd_qc_get_core_stats.html" class="function" rel="rdfs-seeAlso">mysqlnd_qc_get_core_stats()</a> - Statistics collected by the core of the query cache</span>
|
|
</li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |