Mysqlnd query result cache plugin (
mysqlnd_qc
)
2703
match one or many arbitrary characters.
_
will match one arbitrary
character. The escape symbol is backslash.
condition_option
Option for
condition
. Type and structure depend on
condition_type
.
If
condition_type
equals
MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN
condition_options
is the TTL to be used.
Examples
Example 20.326.
mysqlnd_qc_set_cache_condition
example
<?php
/* Cache all accesses to tables with the name "new%" in schema/database "db_example" for 1 second */
if (!mysqlnd_qc_set_cache_condition(MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN, "db_example.new%", 1)) {
die("Failed to set cache condition!");
}
$mysqli = new mysqli("host", "user", "password", "db_example", "port");
/* cached although no SQL hint given */
$mysqli->query("SELECT id, title FROM news");
$pdo_mysql = new PDO("mysql:host=host;dbname=db_example;port=port", "user", "password");
/* not cached: no SQL hint, no pattern match */
$pdo_mysql->query("SELECT id, title FROM latest_news");
/* cached: TTL 1 second, pattern match */
$pdo_mysql->query("SELECT id, title FROM news");
?>
Return Values
Returns TRUE on success or FALSE on FAILURE.
See Also
Quickstart: pattern based caching
20.7.7.7.8.
mysqlnd_qc_set_is_select
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysqlnd_qc_set_is_select
Installs a callback which decides whether a statement is cached
Description
mixed mysqlnd_qc_set_is_select(
string callback);
Installs a callback which decides whether a statement is cached.
There are several ways of hinting PELC/mysqlnd_qc to cache a query. By default, PECL/mysqlnd_qc
attempts to cache a if caching of all statements is enabled or the query string begins with a certain
SQL hint. The plugin internally calls a function named
is_select()
to find out. This internal function
can be replaced with a user-defined callback. Then, the user-defined callback is responsible to decide
whether the plugin attempts to cache a statement. Because the internal function is replaced with
the callback, the callback gains full control. The callback is free to ignore the configuration setting
mysqlnd_qc.cache_by_default
and SQL hints.
The callback is invoked for every statement inspected by the plugin. It is given the statements string
as a parameter. The callback returns
FALSE
if the statement shall not be cached. It returns
TRUE
to
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...