mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-28 14:18:52 +03:00
[cache] Specify cache duration for 'purgeCache'
This commit is contained in:
parent
2d56b717cf
commit
5c309e93dc
3 changed files with 4 additions and 5 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ try {
|
|||
// Initialize cache
|
||||
$cache = Cache::create('FileCache');
|
||||
$cache->setPath(__DIR__ . '/cache');
|
||||
$cache->purgeCache();
|
||||
$cache->purgeCache(86400); // 24 hours
|
||||
$cache->setParameters($params);
|
||||
|
||||
// Load cache & data
|
||||
|
|
|
@ -3,5 +3,5 @@ interface CacheInterface {
|
|||
public function loadData();
|
||||
public function saveData($datas);
|
||||
public function getTime();
|
||||
public function purgeCache();
|
||||
public function purgeCache($duration);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue