mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-21 19:24:47 +02:00
[Cache] Move 'purge' function to implementations
The purge function is cache specific and thus belongs to the specific implementation.
This commit is contained in:
parent
51ff8de346
commit
9ac678aac5
4 changed files with 23 additions and 23 deletions
|
@ -34,6 +34,26 @@ class FileCache extends CacheAbstract {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function purgeCache(){
|
||||
$cacheTimeLimit = time() - 86400; // 86400 -> 24h
|
||||
$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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache is prepared ?
|
||||
* Note : Cache name is based on request information, then cache must be prepare before use
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue