4 var $fileextension = '.cache';
6 function &getInstance() {
8 if (!isset($instance)) {
9 $instance = new CacheService();
14 function CacheService() {
15 $this->basedir = $GLOBALS['dir_cache'];
18 function Start($hash, $time = 300) {
19 $cachefile = $this->basedir .'/'. $hash . $this->fileextension;
20 if (file_exists($cachefile) && time() < filemtime($cachefile) + $time) {
21 @readfile($cachefile);
22 echo "\n<!-- Cached: ". date('r', filemtime($cachefile)) ." -->\n";
26 ob_start("ob_gzhandler");
30 $cachefile = $this->basedir .'/'. $hash . $this->fileextension;
31 $handle = fopen($cachefile, 'w');
32 fwrite($handle, ob_get_contents());