diff --git a/demo.php b/demo.php index 3d0c802..b7c4f53 100644 --- a/demo.php +++ b/demo.php @@ -1,11 +1,12 @@ setPath("./cache"); +$cache->setTTL(3600); + +$item1="Lorem ipsum dolor sit amet"; print "String: \"".$item1."\"\n"; print "Put: "; var_dump($cache->put("lorem",$item1)); diff --git a/inc/Class.PHPCACHER.inc.php b/inc/Class.PHPCACHER.inc.php index 5504199..c1384e7 100644 --- a/inc/Class.PHPCACHER.inc.php +++ b/inc/Class.PHPCACHER.inc.php @@ -7,7 +7,8 @@ class PHPCACHER { } public function get($item) { if ( $this->isCached($item) && $this->isValid($item) ) { - return unserialize(file_get_contents($this->filename($item))); + return unserialize(file_get_contents($this->fileName($item))); + return TRUE; } return FALSE; } @@ -32,24 +33,23 @@ class PHPCACHER { private function fileName($item) { return $this->cachepath."/".md5($item).".data"; } + public function setTTL($ttl) { + $this->cachettl=$ttl; + return TRUE; + } + public function setPath($path) { + $this->cachepath=$path; + if ( !file_exists($this->cachepath) ) { + mkdir($this->cachepath,0755,TRUE); + } + return TRUE; + } } class Cache extends PHPCACHER { function __construct() { - global $phpcacher_ttl; - if ( isset($phpcacher_ttl) ) { - $this->cachettl=$phpcacher_ttl; - } else { - $this->cachettl=3600; - } - global $phpcacher_path; - if ( isset($phpcacher_path) ) { - $this->cachepath=$phpcacher_path; - } else { - $this->cachepath="./cache"; - } - if ( !file_exists($this->cachepath) ) { - mkdir($this->cachepath,0755,TRUE); - } + $this->setTTL(3600); + $this->setPath("./cache"); + return TRUE; } } diff --git a/inc/config.inc.php b/inc/config.inc.php deleted file mode 100644 index 0ddf8fc..0000000 --- a/inc/config.inc.php +++ /dev/null @@ -1,4 +0,0 @@ -