fixes and changes
This commit is contained in:
parent
65b93249a1
commit
e63d73953f
7
demo.php
7
demo.php
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
require_once("inc/config.inc.php");
|
||||
require_once("inc/Class.PHPCACHER.inc.php");
|
||||
|
||||
$item1="Lorem ipsum dolor sit amet";
|
||||
|
||||
$cache = new Cache();
|
||||
$cache->setPath("./cache");
|
||||
$cache->setTTL(3600);
|
||||
|
||||
$item1="Lorem ipsum dolor sit amet";
|
||||
|
||||
print "String: \"".$item1."\"\n";
|
||||
print "Put: "; var_dump($cache->put("lorem",$item1));
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
$phpcacher_ttl=3600;
|
||||
$phpcacher_path="./cache";
|
Loading…
Reference in New Issue
Block a user