
if(!file_exists( $_CacheUrl))
{
$hanld = @fopen( $_CacheUrl,"w");
@fclose( $hanld);
}
if(!file_exists( $_CacheConfigUrl))
{
$hanld = @fopen( $_CacheConfigUrl,"w");
@fclose( $hanld);
}
$this->CacheConfigFile = $_CacheConfigUrl;
$this->CacheFileUrl = $_CacheUrl;
$this->CheckCache();
return true;
}
private function CheckCache()
{
$_FileEditTime = @filemtime( $this->CacheFileUrl);
$_TimeOut = $this->SetTimeOut;
$_IsTimeOut = $_FileEditTime + $_TimeOut;
$this->LastUnixTimePoke = $_FileEditTime;
$this->NextUnixTimePoke = $_IsTimeOut;
$this->CurrentUnixTimePoke = time();
$this->UnixNowToNext = $this->NextUnixTimePoke - time();
$this->LastTimePoke = date("Y-m-d H:i:s", $_FileEditTime);
$this->NextTimePoke = date("Y-m-d H:i:s", $_IsTimeOut);
$this->CurrentTimePoke = date("Y-m-d H:i:s",time());
$_TxtInformation = "上次缓存时间戳: $this->LastUnixTimePoke ";
$_TxtInformation .= "当前缓存时间戳: $this->CurrentUnixTimePoke ";
$_TxtInformation .= "下次缓存时间戳: $this->NextUnixTimePoke ";
$_TxtInformation .= "上次缓存时间: $this->LastTimePoke ";
$_TxtInformation .= "当前缓存时间: $this->CurrentTimePoke ";
$_TxtInformation .= "下次缓存时间: $this->NextTimePoke ";
$_TxtInformation .= "距离下次缓存戳: $this->UnixNowToNext "; $handl = @fopen( $this->CacheConfigFile,’w’);
if( $handl)
{
@fwrite( $handl, $_TxtInformation);
@fclose( $handl);
}
if( $_IsTimeOut >= time())
{
$this->GetCacheData();
}
}
private function ClearCacheFile()
{
@unlink( $this->CacheFileUrl);
@unlink( $this->CacheConfigFile);
}
public function PutCache()
{
$this->DataLength = ob_get_length();
$PutData = ob_get_contents();
if(!file_exists( $this->CacheFileUrl))
{
$CreateOK = $this->CreateCache();
if(! $CreateOK)
{
$this->ErrResponse(’检查缓存文件时产生错误,缓存文件创建失败’);
return false;
}
} else {
$hanld = @fopen( $this->CacheFileUrl,"w");
if( $hanld)
{ if(@is_writable( $this->CacheFileUrl))