【发布时间】:2017-03-03 20:10:07
【问题描述】:
我的 php 代码有问题。我正在使用具有此功能的简单缓存系统。
// Cache Function
function cachestart($min){
global $here;
global $cachefile;
$cachedosyasi = 'cache/' . 'file' . md5($here);
if(file_exists($cachefile) && (time() - $min*60 < filemtime($cachefile))){
include($cachefile);
die;
}else{
ob_start();
global $cache;
$cache = 1;
}
}
function cachefinish(){
global $cache;
global $cachefile;
if(@$cache){
$ch = fopen($cachefile, 'w');
fwrite($ch, ob_get_contents());
fclose($ch);
ob_end_flush();
}
}
我正在尝试:
-- Some Queries (Controls, is user logged etc. )
<< Start Caching >> (With cachestart() )
-- Some Queries (Show entries in database. )
<< Stop Caching >> (With cachefinish() )
-- Some Queries (Comment box)
但我不能这样做,因为“死”。我对此一无所知。
感谢您的帮助!
【问题讨论】:
-
所有查询都再次工作,我看到缓存函数之间的所有内容都翻了一番。编辑:有人说“删除功能中的'死'”,但评论已删除。