Skip to content

Commit ffbdd27

Browse files
committed
Merge pull request #1 from khoaofgod/final
Merge from Main
2 parents 5ee8aad + 7a31773 commit ffbdd27

File tree

5 files changed

+115
-139
lines changed

5 files changed

+115
-139
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,4 @@ $cache->decrementMulti(array(
122122
array("key2", 2),
123123
));
124124

125-
126-
127-
128-
129-
````
125+
```

phpfastcache/3.0.0/drivers/files.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ function __construct($config = array()) {
2828
}
2929

3030
}
31-
31+
3232
private function encodeFilename($keyword) {
33-
return trim(trim(preg_replace("/[^a-zA-Z0-9]+/","_",$keyword),"_"));
33+
return trim(trim(preg_replace("/[^a-zA-Z0-9]+/","_",$keyword),"_"));
3434
// return rtrim(base64_encode($keyword), '=');
3535
}
36-
36+
3737
private function decodeFilename($filename) {
38-
return $filename;
38+
return $filename;
3939
// return base64_decode($filename);
4040
}
4141

@@ -44,8 +44,8 @@ private function decodeFilename($filename) {
4444
*/
4545
private function getFilePath($keyword, $skip = false) {
4646
$path = $this->getPath();
47-
48-
$filename = $this->encodeFilename($keyword);
47+
48+
$filename = $this->encodeFilename($keyword);
4949
$folder = substr($filename,0,2);
5050
$path = rtrim($path,"/")."/".$folder;
5151
/*
@@ -59,7 +59,7 @@ private function getFilePath($keyword, $skip = false) {
5959

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

71-
7271
function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
7372
$file_path = $this->getFilePath($keyword);
7473
// echo "<br>DEBUG SET: ".$keyword." - ".$value." - ".$time."<br>";
@@ -99,9 +98,6 @@ function driver_set($keyword, $value = "", $time = 300, $option = array() ) {
9998
}
10099
}
101100

102-
103-
104-
105101
function driver_get($keyword, $option = array()) {
106102

107103
$file_path = $this->getFilePath($keyword);
@@ -162,19 +158,19 @@ function driver_stats($option = array()) {
162158
$object = $this->decode($this->readfile($file_path));
163159
if($this->isExpired($object)) {
164160
@unlink($file_path);
165-
$removed = $removed + $size;
161+
$removed += $size;
166162
}
167-
$total = $total + $size;
163+
$total += $size;
168164
}
169165
} // end read subdir
170166
} // end if
171167
} // end while
172168

173-
$res['size'] = $total - $removed;
169+
$res['size'] = $total - $removed;
174170
$res['info'] = array(
175-
"Total" => $total,
176-
"Removed" => $removed,
177-
"Current" => $res['size'],
171+
"Total [bytes]" => $total,
172+
"Expired and removed [bytes]" => $removed,
173+
"Current [bytes]" => $res['size'],
178174
);
179175
return $res;
180176
}
@@ -212,10 +208,8 @@ function driver_clean($option = array()) {
212208
} // end if
213209
} // end while
214210

215-
216211
}
217212

218-
219213
function driver_isExisting($keyword) {
220214
$file_path = $this->getFilePath($keyword,true);
221215
if(!@file_exists($file_path)) {
@@ -232,15 +226,11 @@ function driver_isExisting($keyword) {
232226
}
233227

234228
function isExpired($object) {
235-
236229
if(isset($object['expired_time']) && time() >= $object['expired_time']) {
237230
return true;
238231
} else {
239232
return false;
240233
}
241234
}
242235

243-
244-
245-
246236
}

phpfastcache/3.0.0/drivers/predis.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ class phpfastcache_predis extends BasePhpFastCache implements phpfastcache_drive
1616

1717
function checkdriver() {
1818
// Check memcache
19+
if (! class_exists("\\Predis\\Client")) {
1920
$this->required_extension("predis-1.0/autoload.php");
2021
try {
2122
Predis\Autoloader::register();
2223
} catch(Exception $e) {
2324

2425
}
25-
return true;
26+
}
27+
return true;
2628
}
2729

2830
function __construct($config = array()) {
2931
$this->setup($config);
32+
if (! class_exists("\\Predis\\Client")) {
3033
$this->required_extension("predis-1.0/autoload.php");
31-
32-
33-
34+
}
3435
}
3536

3637
function connectServer() {
@@ -121,7 +122,7 @@ function driver_get($keyword, $option = array()) {
121122
function driver_delete($keyword, $option = array()) {
122123

123124
if($this->connectServer()) {
124-
$this->instant->delete($keyword);
125+
$this->instant->del($keyword);
125126
}
126127

127128
}
@@ -164,4 +165,4 @@ function driver_isExisting($keyword) {
164165

165166

166167

167-
}
168+
}

0 commit comments

Comments
 (0)