1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-07 00:56:34 +02:00

[cache] Specify cache duration for 'purgeCache'

This commit is contained in:
logmanoriginal
2016-10-08 16:18:10 +02:00
parent 2d56b717cf
commit 5c309e93dc
3 changed files with 4 additions and 5 deletions

View File

@@ -31,8 +31,7 @@ class FileCache implements CacheInterface {
return false;
}
public function purgeCache(){
$cacheTimeLimit = time() - 86400; // 86400 -> 24h
public function purgeCache($duration){
$cachePath = $this->getPath();
if(file_exists($cachePath)){
$cacheIterator = new RecursiveIteratorIterator(
@@ -44,7 +43,7 @@ class FileCache implements CacheInterface {
if(in_array($cacheFile->getBasename(), array('.', '..')))
continue;
elseif($cacheFile->isFile()){
if(filemtime($cacheFile->getPathname()) < $cacheTimeLimit)
if(filemtime($cacheFile->getPathname()) < time() - $duration)
unlink($cacheFile->getPathname());
}
}