class pagecache {
/**
* @var string $file 缓存文件地址
* @access public
*/
public $file;
/**
* @var int $cachetime 缓存时间
* @access public
*/
public $cachetime = 3600;
/**
* 构造函数
* @param string $file 缓存文件地址
* @param int $cachetime 缓存时间
*/
function __construct($file, $cachetime = 3600) {
$this->file = $file;
$this->cachetime = $cachetime;
}
/**
* 取缓存内容
* @param bool 是否直接输出,true直接转到缓存页,false返回缓存内容
* @return mixed
*/
public function get($output = true) {
if (is_file($this->file) && (time()-filemtime($this->file))<=$this->cachetime && !$_get['nocache']) {
if ($output) {
header('location:' . $this->file);
exit;
} else {
return file_get_contents($this->file);
}
} else {
return false;
}
}
/**
* 设置缓存内容
* @param $content 内容html字符串
*/
public function set($content) {
$fp = fopen($this->file, 'w');
fwrite($fp, $content);
fclose($fp);
}
}
借助RubyGnome2库进行GTK下的Ruby GUI编程的基本方法
哑巴模型Jev使用实用指南:运行机制、原语定义、运行时环境配置及业务场景实用指南
编写Ruby脚本来对Twitter用户的数据进行深度挖掘
从零搭建自己的Codex Plugin Marketplace的实践指南实用指南
如何解决PHPExcel不兼容php7.4版本
thinkphp使用url请求调用ThinkApi天气教程【图文详解】