Added the Cache cleaning system.
This commit is contained in:
parent
a07839019e
commit
f386fc4a10
2 changed files with 24 additions and 5 deletions
lib
|
@ -69,4 +69,24 @@ class Cache{
|
|||
static public function isValidNameCache($nameCache){
|
||||
return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache);
|
||||
}
|
||||
}
|
||||
|
||||
static public function purge() {
|
||||
$cacheTimeLimit = time() - 60*60*24 ;
|
||||
$cachePath = 'cache';
|
||||
if(file_exists($cachePath)) {
|
||||
$cacheIterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($cachePath),
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
foreach ($cacheIterator as $cacheFile) {
|
||||
if (in_array($cacheFile->getBasename(), array('.', '..')))
|
||||
continue;
|
||||
elseif ($cacheFile->isFile()) {
|
||||
if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit )
|
||||
unlink( $cacheFile->getPathname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue