Oracle 5.0 Reference Manual page 2724

Table of Contents

Advertisement

Mysqlnd query result cache plugin (mysqlnd_qc)
make the plugin attempt to cache the statements result set, if any. A so-created cache entry is given
the default TTL set with the PHP configuration directive mysqlnd_qc.ttl. If a different TTL shall be
used, the callback returns a numeric value to be used as the TTL.
The internal
is_select
defined storage handler offers the same capabilities.
Parameters
This function has no parameters.
Return Values
Returns
on success or
TRUE
Examples
Example 20.327.
mysqlnd_qc_set_is_select
<?php
/* callback which decides if query is cached */
function is_select($query) {
static $patterns = array(
/* true - use default from mysqlnd_qc.ttl */
"@SELECT\s+.*\s+FROM\s+test@ismU" => true,
/* 3 - use TTL = 3 seconds */
"@SELECT\s+.*\s+FROM\s+news@ismU" => 3
);
/* check if query does match pattern */
foreach ($patterns as $pattern => $ttl) {
if (preg_match($pattern, $query)) {
printf("is_select(%45s): cache\n", $query);
return $ttl;
}
}
printf("is_select(%45s): do not cache\n", $query);
return false;
}
mysqlnd_qc_set_is_select("is_select");
/* Connect, create and populate test table */
$mysqli = new mysqli("host", "user", "password", "schema");
$mysqli->query("DROP TABLE IF EXISTS test");
$mysqli->query("CREATE TABLE test(id INT)");
$mysqli->query("INSERT INTO test(id) VALUES (1), (2), (3)");
/* cache put */
$mysqli->query("SELECT id FROM test WHERE id = 1");
/* cache hit */
$mysqli->query("SELECT id FROM test WHERE id = 1");
/* cache put */
$mysqli->query("SELECT * FROM test");
?>
The above examples will output:
is_select(
is_select(
is_select(
INSERT INTO test(id) VALUES (1), (2), (3)): do not cache
is_select(
is_select(
is_select(
See Also
function is part of the internal cache storage handler interface. Thus, a user-
on failure.
FALSE
DROP TABLE IF EXISTS test): do not cache
CREATE TABLE test(id INT)): do not cache
SELECT id FROM test WHERE id = 1): cache
SELECT id FROM test WHERE id = 1): cache
SELECT * FROM test): cache
2704
example

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents