myCachable = $cachableClass; $this->maxCacheTime = $maxCacheTimeValue; $this->cachePath = $theCachePath; } function get($key) { $nameOfFileWithCachedData = $this->cachePath . md5(serialize($key)); if (file_exists($nameOfFileWithCachedData)&&(filectime($nameOfFileWithCachedData)>(time()-($this->maxCacheTime)))) { $fp = fopen($nameOfFileWithCachedData,"r"); list($aKey,$aValue) = unserialize(fread($fp,filesize($nameOfFileWithCachedData))); fclose($fp); if ($key == $aKey) { return ($aValue); } else { return ($this->myCachable->get($key)); }; } else { if (file_exists($nameOfFileWithCachedData)) { unlink($nameOfFileWithCachedData); }; $value = $this->myCachable->get($key); $this->set($key,$value); return $value; }; } function set($key,$value) { $nameOfFileWithCachedData = $this->cachePath . md5(serialize($key)); $fp = fopen($nameOfFileWithCachedData,"w"); fwrite($fp,serialize(array($key,$value))); fclose($fp); return $value; } }; ?>