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