Skip to content

Commit

Permalink
Merge pull request #1 from khoaofgod/final
Browse files Browse the repository at this point in the history
Merge from Main
  • Loading branch information
uprel committed Nov 9, 2015
2 parents 5ee8aad + 7a31773 commit ffbdd27
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 139 deletions.
6 changes: 1 addition & 5 deletions README.md
Expand Up @@ -122,8 +122,4 @@ $cache->decrementMulti(array(
array("key2", 2),
));





````
```
36 changes: 13 additions & 23 deletions phpfastcache/3.0.0/drivers/files.php
Expand Up @@ -28,14 +28,14 @@ function __construct($config = array()) {
}

}

private function encodeFilename($keyword) {
return trim(trim(preg_replace("/[^a-zA-Z0-9]+/","_",$keyword),"_"));
return trim(trim(preg_replace("/[^a-zA-Z0-9]+/","_",$keyword),"_"));
// return rtrim(base64_encode($keyword), '=');
}

private function decodeFilename($filename) {
return $filename;
return $filename;
// return base64_decode($filename);
}

Expand All @@ -44,8 +44,8 @@ private function decodeFilename($filename) {
*/
private function getFilePath($keyword, $skip = false) {
$path = $this->getPath();
$filename = $this->encodeFilename($keyword);

$filename = $this->encodeFilename($keyword);
$folder = substr($filename,0,2);
$path = rtrim($path,"/")."/".$folder;
/*
Expand All @@ -59,7 +59,7 @@ private function getFilePath($keyword, $skip = false) {

} elseif(!is_writeable($path)) {
if(!chmod($path,$this->__setChmodAuto())) {
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
throw new Exception("PLEASE CHMOD ".$this->getPath()." - 0777 OR ANY WRITABLE PERMISSION!",92);
}
}
}
Expand All @@ -68,7 +68,6 @@ private function getFilePath($keyword, $skip = false) {
return $file_path;
}


function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
$file_path = $this->getFilePath($keyword);
// echo "<br>DEBUG SET: ".$keyword." - ".$value." - ".$time."<br>";
Expand Down Expand Up @@ -99,9 +98,6 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
}
}




function driver_get($keyword, $option = array()) {

$file_path = $this->getFilePath($keyword);
Expand Down Expand Up @@ -162,19 +158,19 @@ function driver_stats($option = array()) {
$object = $this->decode($this->readfile($file_path));
if($this->isExpired($object)) {
@unlink($file_path);
$removed = $removed + $size;
$removed += $size;
}
$total = $total + $size;
$total += $size;
}
} // end read subdir
} // end if
} // end while

$res['size'] = $total - $removed;
$res['size'] = $total - $removed;
$res['info'] = array(
"Total" => $total,
"Removed" => $removed,
"Current" => $res['size'],
"Total [bytes]" => $total,
"Expired and removed [bytes]" => $removed,
"Current [bytes]" => $res['size'],
);
return $res;
}
Expand Down Expand Up @@ -212,10 +208,8 @@ function driver_clean($option = array()) {
} // end if
} // end while


}


function driver_isExisting($keyword) {
$file_path = $this->getFilePath($keyword,true);
if(!@file_exists($file_path)) {
Expand All @@ -232,15 +226,11 @@ function driver_isExisting($keyword) {
}

function isExpired($object) {

if(isset($object['expired_time']) && time() >= $object['expired_time']) {
return true;
} else {
return false;
}
}




}
13 changes: 7 additions & 6 deletions phpfastcache/3.0.0/drivers/predis.php
Expand Up @@ -16,21 +16,22 @@ class phpfastcache_predis extends BasePhpFastCache implements phpfastcache_drive

function checkdriver() {
// Check memcache
if (! class_exists("\\Predis\\Client")) {
$this->required_extension("predis-1.0/autoload.php");
try {
Predis\Autoloader::register();
} catch(Exception $e) {

}
return true;
}
return true;
}

function __construct($config = array()) {
$this->setup($config);
if (! class_exists("\\Predis\\Client")) {
$this->required_extension("predis-1.0/autoload.php");



}
}

function connectServer() {
Expand Down Expand Up @@ -121,7 +122,7 @@ function driver_get($keyword, $option = array()) {
function driver_delete($keyword, $option = array()) {

if($this->connectServer()) {
$this->instant->delete($keyword);
$this->instant->del($keyword);
}

}
Expand Down Expand Up @@ -164,4 +165,4 @@ function driver_isExisting($keyword) {



}
}

0 comments on commit ffbdd27

Please sign in to comment.