Oracle 5.0 Reference Manual page 2682

Table of Contents

Advertisement

Mysqlnd query result cache plugin (mysqlnd_qc)
set to 1. The setting
mysqlnd_qc.cache_by_default
plugins. Neither the built-in nor user-defined storage handler can overrule the setting.
The SQL hint
/*qc=off*/
mysqlnd_qc.cache_by_default = 1
MYSQLND_QC_DISABLE_SWITCH
Example 20.306. Using the
mysqlnd_qc.enable_qc=1
mysqlnd_qc.cache_by_default=1
<?php
/* Connect, create and populate test table */
$mysqli = new mysqli("host", "user", "password", "schema", "port", "socket");
$mysqli->query("DROP TABLE IF EXISTS test");
$mysqli->query("CREATE TABLE test(id INT)");
$mysqli->query("INSERT INTO test(id) VALUES (1), (2)");
/* Will be cached although no SQL hint is present because of mysqlnd_qc.cache_by_default = 1*/
$res = $mysqli->query("SELECT id FROM test WHERE id = 1");
var_dump($res->fetch_assoc());
$res->free();
$mysqli->query("DELETE FROM test WHERE id = 1");
/* Cache hit - no automatic invalidation and still valid! */
$res = $mysqli->query("SELECT id FROM test WHERE id = 1");
var_dump($res->fetch_assoc());
$res->free();
/* Cache miss - query must not be cached because of the SQL hint */
$res = $mysqli->query("/*" . MYSQLND_QC_DISABLE_SWITCH . "*/SELECT id FROM test WHERE id = 1");
var_dump($res->fetch_assoc());
$res->free();
?>
The above examples will output:
array(1) {
["id"]=>
string(1) "1"
}
array(1) {
["id"]=>
string(1) "1"
}
NULL
PECL/mysqlnd_qc forbids caching of statements for which at least one column from the statements
result set shows no table name in its meta data by default. This is usually the case for columns
originating from SQL functions such as
pitfalls if caching by default is used.
Example 20.307. Example showing which type of statements are not cached
mysqlnd_qc.enable_qc=1
mysqlnd_qc.cache_by_default=1
can be used to disable caching of individual queries if
It is recommended to use the PHP constant
instead of using the string value.
MYSQLND_QC_DISABLE_SWITCH
or LAST_INSERT_ID(). The policy aims to prevent
NOW()
2662
is evaluated by the core of the query cache
SQL hint

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 5.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Mysql 5.0

Table of Contents