update : 2015.11.03
php.shukuma.com검색:
|
Pattern based cachingAn application has three options for telling PECL/mysqlnd_qc whether a particular statement shall be used. The most basic approach is to cache all statements by setting mysqlnd_qc.cache_by_default = 1. This approach is often of little practical value. But it enables users to make a quick estimation about the maximum performance gains from caching. An application designed to use a cache may be able to prefix selected statements with the appropriate SQL hints. However, altering an applications source code may not always be possible or desired, for example, to avoid problems with software updates. Therefore, PECL/mysqlnd_qc allows setting a callback which decides if a query is to be cached.
The callback is installed with the mysqlnd_qc_set_is_select()
function. The callback is given the statement string of every statement
inspected by the plugin. Then, the callback can decide whether to cache
the function. The callback is supposed to return
Example #1 Setting a callback with mysqlnd_qc_set_is_select() mysqlnd_qc.enable_qc=1 mysqlnd_qc.collect_statistics=1
<?php 위 예제들의 출력 예시: is_select( DROP TABLE IF EXISTS test): do not cache is_select( CREATE TABLE test(id INT)): do not cache is_select( INSERT INTO test(id) VALUES (1), (2), (3)): do not cache is_select( SELECT id FROM test WHERE id = 1): cache is_select( SELECT id FROM test WHERE id = 1): cache is_select( SELECT * FROM test): cache Cache put: 2 Cache hit: 1
The examples callback tests if a statement string matches a pattern.
If this is the case, it either returns To minimize application changes the callback can put into and registered in an auto prepend file. |