Refering to :
http://php.net/manual/en/mysqlnd-qc.quickstart.caching.php
PHP Best way to cache MySQL results?
From my undestanding i can make a query get cached on the fly by adding
"/*" . MYSQLND_QC_ENABLE_SWITCH . "*/ "."SELECT ...
in front of my query (example 1 of php.net links above).
The question is, can i do the same, meaning, ask the server to 'reload' the cache on the fly with a single QUERY ?
one answer on SO says i can reset the cache by using
$db->query("RESET QUERY CACHE;");
But this would need an extra call, and i don't necessary want to clear ALL the cached result.
Im doing a select to fecth configuration setting for my platform but i don't want to make a select call for every request (image, json, ajax, etc) so i would cache the results on the 1st request from the client and then use the cached setting for subsequent request. Query will reset cache when a new session start from the client and there a monitoring system to send the user out if a setting change (aka maintenance==true) or the session expired, etc.. so no worries.
That's just one case scenario where i can take advantage of being able to cache and reload cache on the fly. I didn't test anything yet, i just want to know if it is doable before i start digging in the code to patch it up and add 99 bugs at the same time ;)
- i am using mysqli (prepared statement for the most but not exclusively) and NOT PDO.
- i am not using any framework,
- on PHP 5.4.16, centOS 7 and mariaDB 5.5.52 for dev
- CentOs 6, php 5.4.1 with MySQL 5.5.52 in prod.
PRECISION: want/need a query that will, flush cache for this particular query (not all cache), run the query, cache the new results and return the results.
After studies, i found out that http://php.net/manual/en/ref.mysqlnd-qc.php could come at help.