API16

API16:JCacheStorageFile/gc

From Joomla! Documentation

Description

Garbage collect expired cache data


<! removed transcluded page call, red link never existed >

Syntax

gc()


Returns

boolean True on success, false otherwise.

Defined in

libraries/joomla/cache/storage/file.php

Importing

jimport( 'joomla.cache.storage.file' );

Source Body

function gc()
{
        jimport('joomla.filesystem.file');
        $result = true;
        // files older than lifeTime get deleted from cache
        $files = JFolder::files($this->_root, '_expire', true, true);
        foreach($files As $file) {
                $time = @file_get_contents($file);
                if ($time < $this->_now) {
                        $result |= JFile::delete($file);
                        $result |= JFile::delete(str_replace('_expire', '', $file));
                }
        }
        return $result;
}


<! removed transcluded page call, red link never existed >

Examples

Code Examples