mysqlnd_qc_get_cache_info
Returns information on the current handler, the number of cache entries and cache entries, if available
Description
array
mysqlnd_qc_get_cache_info
( void
)
Parameters
This function has no parameters.
Return Values
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.
The scope of the information is the PHP process. Depending on the PHP deployment
model a process may serve one or more web requests.
Values are aggregated for all cache activities on a per storage handler basis.
It is not possible to tell how much queries originating from
mysqli, PDO_MySQL or
mysql.API calls have contributed to the aggregated data values. Use
mysqlnd_qc_get_core_stats
to get timing data aggregated for all storage handlers.
Array of cache information
-
handler
string
-
The active storage handler.
All storage handler. Since 1.0.0.
-
handler_version
string
-
The version of the active storage handler.
All storage handler. Since 1.0.0.
-
num_entries
int
-
The number of cache entries. The value depends on the storage handler in use.
The default, APC and SQLite storage handler provide the actual
number of cache entries.
The MEMCACHE storage handler always returns 0.
MEMCACHE does not support counting the number of cache entries.
If a user defined handler is used, the number of
entries of the data property is reported.
Since 1.0.0.
-
data
array
-
The version of the active storage handler.
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.
Since 1.0.0.
The following information is provided by the default storage handler
for the data property.
The data
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.
-
statistics
array
-
Statistics of the cache entry.
Since 1.0.0.
-
metadata
array
-
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.
The metadata list contains one entry for every column.
Since 1.0.0.
The APC storage handler returns the same information
for the data property but no metadata.
The metadata of a cache entry is set to NULL.
The MEMCACHE storage handler does not fill the data property.
Statistics are not available on a per cache entry basis with the MEMCACHE storage
handler.
A user defined storage handler is free to provide any data.
Examples
Example #1 mysqlnd_qc_get_cache_info example
The example shows the output from the built-in default storage handler.
Other storage handler may report different data.
<?php
/* Populate the cache, e.g. using mysqli */
$mysqli = new mysqli("host", "user", "password", "schema");
$mysqli->query("/*" . MYSQLND_QC_ENABLE_SWITCH . "*/SELECT id FROM test");
/* Display cache information */
var_dump(mysqlnd_qc_get_cache_info());
?>
The above examples will output:
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)
}
}
}
}
}
See Also
-
mysqlnd_qc_get_core_stats