|
|
@ -114,7 +114,7 @@ class Cache
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function gc($ttl, $cacheMaxSize)
|
|
|
|
public function gc($ttl, $maxSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$expire = new \DateTime();
|
|
|
|
$expire = new \DateTime();
|
|
|
|
$expire->modify('-'.$ttl.' seconds');
|
|
|
|
$expire->modify('-'.$ttl.' seconds');
|
|
|
@ -124,12 +124,12 @@ class Cache
|
|
|
|
unlink($file->getRealPath());
|
|
|
|
unlink($file->getRealPath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$totalCacheSize = $this->filesystem->size($this->root);
|
|
|
|
$totalSize = $this->filesystem->size($this->root);
|
|
|
|
if ($totalCacheSize > $cacheMaxSize) {
|
|
|
|
if ($totalSize > $maxSize) {
|
|
|
|
$iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
|
|
|
|
$iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
|
|
|
|
while ($totalCacheSize > $cacheMaxSize && $iterator->valid()) {
|
|
|
|
while ($totalSize > $maxSize && $iterator->valid()) {
|
|
|
|
$filepath = $iterator->current()->getRealPath();
|
|
|
|
$filepath = $iterator->current()->getRealPath();
|
|
|
|
$totalCacheSize -= $this->filesystem->size($filepath);
|
|
|
|
$totalSize -= $this->filesystem->size($filepath);
|
|
|
|
unlink($filepath);
|
|
|
|
unlink($filepath);
|
|
|
|
$iterator->next();
|
|
|
|
$iterator->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|