Skip to content

Commit 55e759e

Browse files
committed
Improved stats function for files driver. Before data property was empty now it contains array of all keys in cache with each holding array of size and write time.
1 parent ffbdd27 commit 55e759e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

phpfastcache/3.0.0/drivers/files.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ function driver_stats($option = array()) {
143143

144144
$total = 0;
145145
$removed = 0;
146+
$content = array();
146147
while($file=@readdir($dir)) {
147148
if($file!="." && $file!=".." && is_dir($path."/".$file)) {
148149
// read sub dir
@@ -156,6 +157,14 @@ function driver_stats($option = array()) {
156157
$file_path = $path."/".$file."/".$f;
157158
$size = @filesize($file_path);
158159
$object = $this->decode($this->readfile($file_path));
160+
161+
if(strpos($f,".") === false) {
162+
$key = $f;
163+
}
164+
else {
165+
$key = explode(".", $f)[0];
166+
}
167+
$content[$key] = array("size"=>$size,"write_time"=>$object["write_time"]);
159168
if($this->isExpired($object)) {
160169
@unlink($file_path);
161170
$removed += $size;
@@ -172,6 +181,7 @@ function driver_stats($option = array()) {
172181
"Expired and removed [bytes]" => $removed,
173182
"Current [bytes]" => $res['size'],
174183
);
184+
$res["data"] = $content;
175185
return $res;
176186
}
177187

0 commit comments

Comments
 (0)