MySQL native driver for PHP: The query cache plugin
mysqlnd_qc:  The query cache plugin  Ulf Wendel, Andrey Hristov MySQL Connectors Team Sun Microsystems
Table of Contents <ul><li>At a glance </li><ul><li>Key Features
Basic Usage </li></ul><li>Architecture </li><ul><li>MySQLnd Plugins
Cache Architecture
Storage handler </li></ul><li>Usage </li><ul><li>Advanced Usage
Configuration </li></ul></ul>
Key Features <ul><li>Transparent: no user API changes </li><ul><li>supports ext/mysqli
supports PDO_MYSQL
supports ext/mysql </li></ul><li>Invalidation: TTL, custom </li><ul><li>Per query TTL (Time to Live)
custom: user callbacks </li></ul><li>Storage handler: build-in, custom </li><ul><li>Default (Hash), APC, Memcache
custom: user callbacks </li></ul></ul>
Possibly asked questions <ul><li>Can stale data be served? </li><ul><li>Sure, it is Time to live (TTL) by default! But you...
Only buffered queries can be cached <ul><li>ext/mysqli </li><ul><li>mysqli_query()
mysqli_real_query() + mysqli_store_result() </li></ul><li>PDO_MYSQL </li><ul><li>PDO::query() if PDO::ATTR_EMULATE_PREPARE...
(this is the default) </li></ul><li>ext/mysql </li><ul><li>mysql_query() </li></ul></ul>
Uncachable queries <ul><li>ext/mysqli </li><ul><li>mysqli_real_query() + mysqli_use_result()
mysqli_query() + MYSQLI_ASYNC
mysqli_stmt_*() </li></ul><li>PDO_MYSQL </li><ul><li>PDO::query() if PDO::ATTR_EMULATE_PREPARES = 0 </li></ul><li>ext/mysq...
Benchmarks? <ul><li>Please run your own! </li><ul><li>Too many variables, sorry... for now ;-)
Chart compares handler – no more </li></ul></ul>
f Basic Usage $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);; // Cached: SQL hint used $res = $mysqli->...
Installation <ul><li>Download source </li><ul><li>http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP </li></ul...
./configure --help | grep mysql
./configure --help | grep qc
make clean && make </li></ul></ul>
Compared to MySQL Server Cache <ul><li>Different location! </li><ul><li>Less work for the server
Shorter distance to the app (round trip times)
Scale by client
No server overload
Less sophisticated invalidation (stale data!) </li></ul></ul>
Compared to Memcache <ul><li>Memcache is no cache </li><ul><li>Memcache is a storage medium
Often used for storing cached data
We offer a Memcache storage handler </li></ul><li>Application vs. driver based caching </li><ul><li>almost no application ...
caching of raw data instead of processed data </li></ul></ul>
Table of Contents <ul><li>At a glance </li><ul><li>Key Features
Basic Usage </li></ul><li>Architecture </li><ul><li>MySQLnd Plugins
Cache Architecture
Storage handler </li></ul><li>Usage </li><ul><li>Customization
Configuration </li></ul></ul>
How PHP connects to MySQL  PHP MySQL Server Library: implements MySQL Client-Server Protocol PHP API for PHP applications ...
Inside PHP (on the C level!) PHP Extensions Zend Engine PDO ext/mysql ext/mysqli SAPI PDO_MYSQL PDO_XYZ MySQL Client Libra...
PHP 5.3.2: mysqlnd plugin interface <?php  /* Any PHP MySQL application */  ?> ext/*mysql* ext/*mysql* Plugin MySQL native...
“Object-orientation” in mysqlnd <?php  mysqli_query($link, … ); ?> Inside mysqlnd: “objects” of data and function pointer ...
Plugins as “Proxies” or “Decorators” <?php  mysqli_query($link, … ); ?> Plugins replace or extend internal mysqlnd objects...
Plugins can change everything <ul><li>Connection methods </li><ul><li>sending queries, fetching results
metadata access
utility calls </li></ul><li>Prepared Statement methods </li><ul><li>sending queries, fetching results
… </li></ul><li>Network calls </li><ul><li>send and fetch raw MySQL protocol data </li></ul></ul>
C level support for Plugins <ul><li>API calls </li><ul><li>Plugin registration
management of function tables </li></ul><li>Piggybacking data </li><ul><li>via connection object
via result set object
via statistics hash </li></ul></ul>
Query cache: proxy-style plugin Cache MySQL <?php  /* Any PHP MySQL application */  ?> ext/*mysql* ext/*mysql* mysqlnd mys...
Query Cache: Miss mysqlnd orig. mysqlnd_conn object mysqlnd_qc object query()  Should cache? Yes! Is cached? No! Activate ...
Query Cache: Hit mysqlnd mysqlnd_qc object query()  Should cache? Yes! Is cached? Yes! Fetch data from cache Decode data
Storage handler responsibilities <ul><li>Storage </li><ul><li>Scope: request, process, machine, multi-machine
Location: distance to cache
Replacement strategy
Slam defense strategy </li></ul><li>Decide what to cache </li><ul><li>Detect SELECT statements
Parse SQL-Hints </li></ul><li>Extended statistics </li><ul><li>Storage statistics, traces, timings </li></ul></ul>
Cache storage handler (I) <ul><li>Default (Hash) </li><ul><li>Scope: process (single or multiple requests)
Upcoming SlideShare
Loading in...5
×

Built-in query caching for all PHP MySQL extensions/APIs

8,313

Published on

Query caching boosts the performance of PHP MySQL applications. Caching can be done on the database server or at the web clients. A new mysqlnd plugin adds query caching to all PHP MySQL extension: written in C, immediately usable with any PHP application because of no API changes, supports Memcache, APC, SQLite and main memory storage, integrates itself smoothless into existing PHP deployment infrastructure, helps you to scale by client, ... Enjoy!

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,313
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
105
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Built-in query caching for all PHP MySQL extensions/APIs

  1. 1. MySQL native driver for PHP: The query cache plugin
  2. 2. mysqlnd_qc: The query cache plugin Ulf Wendel, Andrey Hristov MySQL Connectors Team Sun Microsystems
  3. 3. Table of Contents <ul><li>At a glance </li><ul><li>Key Features
  4. 4. Basic Usage </li></ul><li>Architecture </li><ul><li>MySQLnd Plugins
  5. 5. Cache Architecture
  6. 6. Storage handler </li></ul><li>Usage </li><ul><li>Advanced Usage
  7. 7. Configuration </li></ul></ul>
  8. 8. Key Features <ul><li>Transparent: no user API changes </li><ul><li>supports ext/mysqli
  9. 9. supports PDO_MYSQL
  10. 10. supports ext/mysql </li></ul><li>Invalidation: TTL, custom </li><ul><li>Per query TTL (Time to Live)
  11. 11. custom: user callbacks </li></ul><li>Storage handler: build-in, custom </li><ul><li>Default (Hash), APC, Memcache
  12. 12. custom: user callbacks </li></ul></ul>
  13. 13. Possibly asked questions <ul><li>Can stale data be served? </li><ul><li>Sure, it is Time to live (TTL) by default! But you can implement your own invalidation strategy. </li></ul><li>Which PHP versions are supported? </li><ul><li>PHP 5.3.3-dev or newer. At the time of writing the query cache is in prototype stage. </li></ul><li>Where can I get it? </li><ul><li>http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP </li></ul></ul>
  14. 14. Only buffered queries can be cached <ul><li>ext/mysqli </li><ul><li>mysqli_query()
  15. 15. mysqli_real_query() + mysqli_store_result() </li></ul><li>PDO_MYSQL </li><ul><li>PDO::query() if PDO::ATTR_EMULATE_PREPARES = 1
  16. 16. (this is the default) </li></ul><li>ext/mysql </li><ul><li>mysql_query() </li></ul></ul>
  17. 17. Uncachable queries <ul><li>ext/mysqli </li><ul><li>mysqli_real_query() + mysqli_use_result()
  18. 18. mysqli_query() + MYSQLI_ASYNC
  19. 19. mysqli_stmt_*() </li></ul><li>PDO_MYSQL </li><ul><li>PDO::query() if PDO::ATTR_EMULATE_PREPARES = 0 </li></ul><li>ext/mysql </li><ul><li>mysql_unbuffered_query() </li></ul></ul>
  20. 20. Benchmarks? <ul><li>Please run your own! </li><ul><li>Too many variables, sorry... for now ;-)
  21. 21. Chart compares handler – no more </li></ul></ul>
  22. 22. f Basic Usage $mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket);; // Cached: SQL hint used $res = $mysqli->query(&quot;/*qc=on*/&quot; . &quot;SELECT id, label FROM test&quot;); var_dump($res->fetch_all(MYSQLI_ASSOC)); $res->free(); SQL hint /*qc=on*/ to control caching // Uncached: no SQL hint $res = $mysqli->query(&quot;SELECT id, label FROM test&quot;); var_dump($res->fetch_all(MYSQLI_ASSOC)); $res->free();
  23. 23. Installation <ul><li>Download source </li><ul><li>http://forge.mysql.com/wiki/MySQLnd_Query_Cache_Plugin_for_PHP </li></ul><li>Copy extension into PHP 5.3.3+ source tree </li><ul><li>cp -R query_cache my_php/ext/mysqlnd_qc </li></ul><li>Enable query cache and build </li><ul><li>./buildconf --force
  24. 24. ./configure --help | grep mysql
  25. 25. ./configure --help | grep qc
  26. 26. make clean && make </li></ul></ul>
  27. 27. Compared to MySQL Server Cache <ul><li>Different location! </li><ul><li>Less work for the server
  28. 28. Shorter distance to the app (round trip times)
  29. 29. Scale by client
  30. 30. No server overload
  31. 31. Less sophisticated invalidation (stale data!) </li></ul></ul>
  32. 32. Compared to Memcache <ul><li>Memcache is no cache </li><ul><li>Memcache is a storage medium
  33. 33. Often used for storing cached data
  34. 34. We offer a Memcache storage handler </li></ul><li>Application vs. driver based caching </li><ul><li>almost no application changes needed
  35. 35. caching of raw data instead of processed data </li></ul></ul>
  36. 36. Table of Contents <ul><li>At a glance </li><ul><li>Key Features
  37. 37. Basic Usage </li></ul><li>Architecture </li><ul><li>MySQLnd Plugins
  38. 38. Cache Architecture
  39. 39. Storage handler </li></ul><li>Usage </li><ul><li>Customization
  40. 40. Configuration </li></ul></ul>
  41. 41. How PHP connects to MySQL PHP MySQL Server Library: implements MySQL Client-Server Protocol PHP API for PHP applications MySQL native driver for PHP / MySQL Client Library
  42. 42. Inside PHP (on the C level!) PHP Extensions Zend Engine PDO ext/mysql ext/mysqli SAPI PDO_MYSQL PDO_XYZ MySQL Client Library (libmysql) or MySQL native driver for PHP (default as of PHP 5.3)
  43. 43. PHP 5.3.2: mysqlnd plugin interface <?php /* Any PHP MySQL application */ ?> ext/*mysql* ext/*mysql* Plugin MySQL native driver for PHP C plugins operate transparently: no user API changes
  44. 44. “Object-orientation” in mysqlnd <?php mysqli_query($link, … ); ?> Inside mysqlnd: “objects” of data and function pointer mysqlnd_connection connection_methods host user password ... connection_methods query() store_result() use_result() free_result() ...
  45. 45. Plugins as “Proxies” or “Decorators” <?php mysqli_query($link, … ); ?> Plugins replace or extend internal mysqlnd objects connection_methods query() store_result() use_result() free_result() ... Plugin query() store_result() use_result() free_result() ... mysqlnd_connection connection_methods host user password ...
  46. 46. Plugins can change everything <ul><li>Connection methods </li><ul><li>sending queries, fetching results
  47. 47. metadata access
  48. 48. utility calls </li></ul><li>Prepared Statement methods </li><ul><li>sending queries, fetching results
  49. 49. … </li></ul><li>Network calls </li><ul><li>send and fetch raw MySQL protocol data </li></ul></ul>
  50. 50. C level support for Plugins <ul><li>API calls </li><ul><li>Plugin registration
  51. 51. management of function tables </li></ul><li>Piggybacking data </li><ul><li>via connection object
  52. 52. via result set object
  53. 53. via statistics hash </li></ul></ul>
  54. 54. Query cache: proxy-style plugin Cache MySQL <?php /* Any PHP MySQL application */ ?> ext/*mysql* ext/*mysql* mysqlnd mysqlnd Cache miss: record wire data, cache hit: replay Query Cache Plugin
  55. 55. Query Cache: Miss mysqlnd orig. mysqlnd_conn object mysqlnd_qc object query() Should cache? Yes! Is cached? No! Activate data recorder query() Send query to MySQL Deactivate recorder Cache wire data Decode data Fetch reply
  56. 56. Query Cache: Hit mysqlnd mysqlnd_qc object query() Should cache? Yes! Is cached? Yes! Fetch data from cache Decode data
  57. 57. Storage handler responsibilities <ul><li>Storage </li><ul><li>Scope: request, process, machine, multi-machine
  58. 58. Location: distance to cache
  59. 59. Replacement strategy
  60. 60. Slam defense strategy </li></ul><li>Decide what to cache </li><ul><li>Detect SELECT statements
  61. 61. Parse SQL-Hints </li></ul><li>Extended statistics </li><ul><li>Storage statistics, traces, timings </li></ul></ul>
  62. 62. Cache storage handler (I) <ul><li>Default (Hash) </li><ul><li>Scope: process (single or multiple requests)
  63. 63. Location: same process
  64. 64. User can flush cache
  65. 65. Handler maintains storage statistics </li></ul><li>APC </li><ul><li>Scope: machine (multiple requests)
  66. 66. Location: local
  67. 67. User can flush cache
  68. 68. Handler maintains storage statistics </li></ul></ul>
  69. 69. Cache storage handler (II) <ul><li>Memcache </li><ul><li>Scope: can be shared between machines
  70. 70. Location: can be local or remote
  71. 71. User cannot flush cache
  72. 72. No handler statistics </li></ul><li>NOP </li><ul><li>No operation
  73. 73. Internal and not exposed to PHP land </li></ul></ul>
  74. 74. Cache storage handler (III) <ul><li>SQLite </li><ul><li>Scope, if using “:memory:”: process (single or multiple requests)
  75. 75. Scope, if using file: single (multiple) machine
  76. 76. Location: can be local or remote
  77. 77. User can flush cache
  78. 78. Handler maintains storage statistics </li></ul><li>Berkeley DB </li><ul><li>theoretically usable via the new SQLite C API compatibility wrapper </li></ul></ul>
  79. 79. Cache storage handler (IV) <ul><li>User (procedural and object oriented) </li><ul><li>It is all up to you! </li></ul><li>User (class mysqlnd_qc_handler_default) </li><ul><li>Default handler behaviour
  80. 80. Can be specialized by user
  81. 81. User can specialize one, many or all functions </li></ul><li>See also extra presentation! </li></ul>
  82. 82. Cache Architecture Summary <ul><li>Transparent from a user perspective </li><ul><li>No user API changes
  83. 83. Works with all user APIs </li></ul><li>Stores raw wire data </li><ul><li>Pro: Simplicity – low risk of bugs!
  84. 84. Con: Client always needs to decode </li></ul><li>Storage handler </li><ul><li>Choice of life-span and scope
  85. 85. Choice of distance to client </li></ul></ul>
  86. 86. Cache Miss Client 2...100 Client 2...100 Client 2...100 BTW, plan your cache carefully! What if a shared cache entry expires? Client 1 Client 2...n Cache Hit MySQL Client 2...100 Client 2...100 Client 2...100 Client 1 Client 2...n MySQL
  87. 87. Cache Miss Optimize storage for reuse? Memory consumption versus peak loads Client 1 Client 2 MySQL Client 2...100 Client 2...100 Client 2...100 Client 1 Client 2...n MySQL Cache Miss Cache Hit Client 3..n
  88. 88. Table of Contents <ul><li>At a glance </li><ul><li>Key Features
  89. 89. Basic Usage </li></ul><li>Architecture </li><ul><li>MySQLnd Plugins
  90. 90. Cache Architecture
  91. 91. Storage handler </li></ul><li>Usage </li><ul><li>Advanced Usage
  92. 92. Configuration </li></ul></ul>
  93. 93. Customization: user handler <ul><li>Procedural and OOP interfaces
  94. 94. Control which query gets cached
  95. 95. Control where to store cached data
  96. 96. Implement your own invalidation strategy
  97. 97. Maintain your own statistics </li></ul>
  98. 98. Procedural and OOP user handler <ul><li>mysqlnd_qc_set_user_handlers() </li><ul><li>procedural
  99. 99. you must implement all storage handler functions </li></ul><li>extending class mysqlnd_qc_handler_default </li><ul><li>object oriented
  100. 100. customize build-in default handler
  101. 101. no need to spezialize all handler functions </li></ul><li>implementing interface mysqlnd_qc_handler </li><ul><li>object oriented
  102. 102. you must implement all storage handler functions </li></ul></ul>
  103. 103. Procedural user storage handler void mysqlnd_qc_set_user_handlers( string get_hash_key, string find_query_in_cache, string return_to_cache, string add_query_to_cache_if_not_exists, string query_is_select, string update_cache_stats, string clear_cache ) Yes, this API may be ugly. BUT: Prototype! BUT: See extra presentation for vodoo! mysqlnd_qc_set_user_handlers()
  104. 104. User storage handler interface (I) function get_hash($host_info, $port, $user, $db, $query) { /* returns string */ return $key; } function find($key) { /* returns boolean */ return $found; } function return_to_cache($key) { /* void – leave empty */ } function add($key, $data, $ttl, $runtime, $store_time, $row_count) { /* returns boolean */ return $added_to_cache; }
  105. 105. User storage handler interface (II) function query_is_select($query) { /* returns mixed - boolean false if the query shall not be cached boolean true or double 0 to use mysqlnd_qc.ttl default double >= 0 to set TTL different from mysqlnd_qc.ttl */ return $to_cache_or_not; } function update_stats($key, $run_time, $store_time) { /* void – data to update your per query cache statistics *// } function clear_cache() { /* returns boolean */ return $cache_has_been_flushed; }
  106. 106. Object oriented storage handler <ul><li>implementing interface mysqlnd_qc_handler
  107. 107. extending mysqlnd_qc_handler_default
  108. 108. See also extra presentation! </li></ul>
  109. 109. API calls <ul><li>mysqlnd_qc_change_handler()
  110. 110. mysqlnd_qc_clear_cache()
  111. 111. mysqlnd_qc_get_cache_info()
  112. 112. mysqlnd_qc_get_core_stats()
  113. 113. mysqlnd_qc_get_handler()
  114. 114. mysqlnd_qc_get_normalized_query_trace_log()
  115. 115. mysqlnd_qc_get_query_trace_log()
  116. 116. mysqlnd_qc_set_user_handlers() </li></ul>
  117. 117. Changing the storage handler bool mysqlnd_qc_change_handler(string handler) Changes the storage handler. Returns false if the current handler cannot be shutdown or the requested handler cannot be initialized. Failing to change the handler should be considered as a fatal error unless the change fails because the requested handler is unknown.
  118. 118. Procedural user storage handler void mysqlnd_qc_set_user_handlers( string get_hash_key, string find_query_in_cache, string return_to_cache, string add_query_to_cache_if_not_exists, string query_is_select, string update_cache_stats, string clear_cache ) Sets the function names of a user defined storage handler and puts them into use. See also extra presentation!
  119. 119. Available handlers array mysqlnd_qc_get_handlers() Returns a list of available handler and their versions. The handler “default”, “user”, the class “ myslqnd_qc_handler_default” are always available. “ apc” and “memcache” will be reported if support for those handlers has been enabled at compile time.
  120. 120. Flushing the cache The function is not supported by the Memcache handler! bool mysqlnd_qc_clear_cache() Returns true if the handler supports the operation, and has flushed the cache.
  121. 121. Cache info and handler statistics // Run some queries and generate cache hits $res = $mysqli->query(&quot;/*qc=1*/&quot; . &quot;SELECT id, label FROM test&quot;); var_dump($res->fetch_all(MYSQLI_ASSOC)); C-based handler cache information and statistics var_dump(mysqlnd_qc_get_cache_info()); array(4) { [&quot;num_entries&quot;]=> int(%d) [&quot;handler&quot;]=> string(7) &quot;default&quot; [&quot;handler_version&quot;]=> string(5) &quot;1.0.0&quot; [&quot;data&quot;]=> array(%d) { [&quot;%s”] => array(2) { [“statistics”] => array(...), [“metadata”] => array(...) } [, ...] }
  122. 122. Cache hits, time statistics and more <ul><li>Remember: handler specific statistics </li><ul><li>Memcache: no statistics at all
  123. 123. APC: no metadata </li></ul><li>If available: </li><ul><li>num_entries: number of cache entries
  124. 124. [“data”][key][“statistics”] : run/store time statistics
  125. 125. [“data”][key][“statistics”] : cache hits
  126. 126. [“data”][key][“metadata”]: result set meta data </li></ul><li>See also extra presentation! </li></ul>
  127. 127. Core statistics php.ini setting: mysqlnd_qc_collect_statistics = 1 array mysqlnd_qc_get_core_statistics() Returns a list 20+ statistics collected by the core of the query cache plugin, if the PHP configuration setting mysqlnd_qc_collect_statistics is set to 1. The statistics are provided by the core and therefore available with all storage handlers and when using user-defined storage handlers. The statistics cover cache accesses, failures, network traffic as well as aggregated run and store times.
  128. 128. Query back trace php.ini setting: mysqlnd_qc.query_trace = 1 array mysqlnd_qc_get_query_trace_log() Returns a query back trace for every query that has been inspected by the query cache regardless if the query ended up being cached or not. The trace tells you where a query has been issues (see also debug_backtrace()). Together with the back trace you get run and store times and information on if the query has been cached.
  129. 129. Normalized query back trace mysqlnd_qc.collect_normalized_query_trace = 1 array mysqlnd_qc_get_normalized_query_trace_log() Similar to mysqlnd_qc_get_query_trace_log() but with SQL statements normalized and aggregated by the normalized query string. Normalization refers to replacing actual parameters, for example in “WHERE a > 1”, with questionmarks like “ WHERE a > ?”. “WHERE a > ?” will match any value for “?”, for example “1”, “2”, “'abc'” but not other identifiers.
  130. 130. Runtime configuration
  131. 131. Runtime configuration (cont.)
  132. 132. Basics <ul><li>mysqlnd_qc.ttl </li><ul><li>Time to live in seconds
  133. 133. Handler can overrule setting for individual queries </li></ul><li>mysqlnd_qc.cache_by_default </li><ul><li>Cache every query, even those without SQL hint?
  134. 134. Evaluated by the core, handler cannot overrule! </li></ul><li>mysqlnd_qc.cache_no_table </li><ul><li>Cache queries with no table name im their meta data, e.g SELECT SLEEP(1)? </li></ul></ul>
  135. 135. Performance <ul><li>mysqlnd_qc.use_request_time </li><ul><li>Use PHP global request time to avoid gettimeofday() system calls?
  136. 136. Pitfall – see APC docs on apc.use_request_time </li></ul><li>mysqlnd_qc.time_statistics </li><ul><li>Collect run time and store time statistics using gettimeofday() system call? </li></ul><li>mysqlnd_qc.std_data_copy </li><ul><li>Default handler: copy cached wire data?
  137. 137. EXPERIMENTAL – use default of “0” </li></ul></ul>
  138. 138. Statistics and Slam defense <ul><li>mysqlnd_qc.collect_statistics </li><ul><li>Collect statistics for mysqlnd_qc_get_core_stats()? </li></ul><li>mysqlnd_qc.slam_defense </li><ul><li>Activates handler based slam defense if available </li></ul></ul>
  139. 139. Query traces <ul><li>mysqlnd_qc.collect_query_trace </li><ul><li>Collect query back traces? </li></ul><li>mysqlnd_qc.query_trace_bt_depth </li><ul><li>Maximum back trace depth </li></ul><li>mysqlnd_qc.collect_normalized_query_trace </li><ul><li>Collect aggregated normalized query traces? </li></ul></ul>
  140. 140. APC storage handler <ul><li>mysqlnd_qc.use_request_time = apc.use_request time </li><ul><li>Use the same timer for TTL invalidation </li></ul><li>mysqlnd_qc.apc_prefix </li><ul><li>Key prefix
  141. 141. APC handler stores data in the APC user cache
  142. 142. Users can manipulate the cache entries! </li></ul></ul>
  143. 143. Memcache storage handler <ul><li>mysqlnd_qc.memc_server </li><ul><li>Memcache server host
  144. 144. Cannot be changed at run time </li></ul><li>mysqlnd_qc.memc_port </li><ul><li>Memcache server port </li></ul></ul>
  145. 145. SQLite storage handler <ul><li>mysqlnd_qc.sqlite_data_file </li><ul><li>SQLite data file
  146. 146. You should use SQLite as an in-memory storage </li></ul></ul>
  147. 147. Exported PHP constants <ul><li>MYSQLND_QC_ENABLE_SWITCH </li><ul><li>SQL-hint to enable caching, e.g. “qc=on”
  148. 148. Only this exact string will recognized! </li></ul><li>MYSQLND_QC_DISABLE_SWITCH </li><ul><li>SQL-hint to disable caching, e.g. “qc=off”
  149. 149. Only this exact string will be recognized! </li></ul><li>MYSQLND_QC_TTL_SWITCH </li><ul><li>SQL-hint for setting per query TTL, e.g. “qc_ttl=”
  150. 150. All constants can be changed as compile time! </li></ul></ul>
  151. 151. Exported PHP classes class mysqlnd_qc_handler_default { public function init() {} public function is_select(...) {} public function get_hash_key(...) {} public function return_to_cache(...) {} public function add_to_cache(...) {} public function find_in_cache(...) {} public function update_cache_stats(...) {} public function get_stats(...) {} public function clear_cache() {} public function shutdown() {} }
  152. 152. Exported PHP interfaces interface mysqlnd_qc_handler { public function is_select(...) {} public function get_hash_key(...) {} public function return_to_cache(...) {} public function add_to_cache(...) {} public function find_in_cache(...) {} public function update_cache_stats(...) {} public function get_stats(...) {} public function clear_cache() {} }
  153. 153. <ul><li>Presentations </li><ul><li>A query cache plugin -
  154. 154. this is what you look at ;-)
  155. 155. Query cache plugin benchmark impressions
  156. 156. Dig deeper with QC statistics
  157. 157. Developing user storage handler </li></ul></ul>Further reading
  158. 158. The End Feedback: ulf.wendel@sun.com The End Feedback: [email_address] , [email_address]
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×