前提:我不是要重新发明轮子,我只是想了解一下.
输出缓存可以轻松实现:
//GetFromMyCache returns the page if it finds the file otherwise returns FALSE
if( ($page = GetFromMyCache($page_id)) !== FALSE )
{
echo $page; //sending out page from cache
exit();
}
//since we reach this point in code, it means page was not in cache
ob_start(); //let's start caching
//we process the page getting data from DB
//saving processed page in cache and flushing it out
echo CachePageAndFlush(ob_get_contents());
Run Code Online (Sandbox Code Playgroud)
但接下来是APC (默认情况下将包含在PHP6中).
APC是否曾经安装在服务器上的模块,现有的 PHP代码运行速度更快, …