You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You "can't" cache "a query", bro - BUT you "can" cache "a result" of query.
// Get from cache first$result = phpFastCache::get("name");
// IF nothing in cacheif($result == null) {
$query = mysql_query("SELECT * FROM `abc` WHERE 1");
$result = mysql_fetch_array($query);
// write to cache, and use it on next 600 seconds - Your PHP will not send query until cache is expired.
phpFastCache::set("name",$result,600);
}
return$result or print_r($result);
// Get from cache first$result = phpFastCache::get("name");
// IF nothing in cacheif($result == null) {
// Actually, this part will be put in function, not like this. $query = mysql_query("SELECT * FROM `abc` WHERE 1");
$result = array();
while($ht = mysql_fetch_array($query)) {
$result[] = $ht;
}
// write to cache, and use it on next 600 seconds - Your PHP will not send query until cache is expired.
phpFastCache::set("name",$result,600);
}
return$result or print_r($result);
I couldn't cache mysql queries. Can you show an example pls?
The text was updated successfully, but these errors were encountered: