PHP完全自学手册(珍藏版) 中文pdf扫描版下载
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 5 ))) { // Cache file is less than five minutes old. // Don't bother refreshing, just use the file as-is. $file = file_get_contents($cache_file); } else { // Our cache is out-of-date, so load the data from our remote server, // and also save it over our cache for next time. $file = file_get_contents($url); file_put_contents($cache_file, $file, LOCK_EX); }
转载请注明:谷谷点程序 » php简单实现缓存的方法