&reftitle.constants;
&extension.constants;
SQL hint relatedUsing SQL hint constants
The query cache is controlled by SQL hints. SQL hints are used to enable and
disable caching. SQL hints can be used to set the
TTL of a query.
The SQL hints recognized by the query cache can be manually changed at
compile time. This makes it possible to use
mysqlnd_qc in environments in which the default
SQL hints are already taken and interpreted by other systems. Therefore
it is recommended to use the SQL hint string constants instead of
manually adding the default SQL hints to the query string.
]]>
&examples.outputs;
MYSQLND_QC_ENABLE_SWITCH
(string)
SQL hint used to enable caching of a query.
MYSQLND_QC_DISABLE_SWITCH
(string)
SQL hint used to disable caching of a query if
mysqlnd_qc.cache_by_default = 1.
MYSQLND_QC_TTL_SWITCH
(string)
SQL hint used to set the TTL of a result set.
MYSQLND_QC_SERVER_ID_SWITCH
(string)
This SQL hint should not be used in general.
It is needed by PECL/mysqlnd_ms
to group cache entries for one statement
but originating from different physical connections. If the
hint is used connection settings such as user, hostname and charset
are not considered for generating a cache key of a query.
Instead the given value and the query string are used as input
to the hashing function that generates the key.
PECL/mysqlnd_ms may, if instructed, cache results from
MySQL Replication slaves. Because it can hold many connections
to the slave the cache key shall not be formed from the user,
hostname or other settings that may vary for the various slave
connections. Instead, PECL/mysqlnd_ms provides an identifier
which refers to the group of slave connections that shall be enabled
to share cache entries no matter which physical slave connection was
to generate the cache entry.
Use of this feature outside of PECL/mysqlnd_ms is not recommended.
mysqlnd_qc_set_cache_condition relatedExample mysqlnd_qc_set_cache_condition usage
The function mysqlnd_qc_set_cache_condition allows setting conditions
for automatic caching of statements which don't begin with the SQL hints
necessary to manually enable caching.
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");
?>
]]>
MYSQLND_QC_CONDITION_META_SCHEMA_PATTERN
(int)
Used as a parameter of mysqlnd_qc_set_cache_condition
to set conditions for schema based automatic caching.
Other
The plugin version number can be obtained using either
MYSQLND_QC_VERSION, which is the string representation
of the numerical version number, or MYSQLND_QC_VERSION_ID,
which is an integer such as 10000. Developers can calculate the version number
as follows.
Version (part)ExampleMajor*100001*10000 = 10000Minor*1000*100 = 0Patch0 = 0MYSQLND_QC_VERSION_ID10000MYSQLND_QC_VERSION
(string)
Plugin version string, for example, 1.0.0-prototype.
MYSQLND_QC_VERSION_ID
(int)
Plugin version number, for example, 10000.