Back to FileStorage class

Method _checkExpire

protected bool
_checkExpire
(mixed $id, mixed $group)
Check if a cache object has expired
Parameters
  • string $id Cache ID to check
  • string $group The cache data group
Returns
  • bool True if the cache ID is valid
Since
  • 1.7.0
Class: FileStorage
Project: Joomla

Method _checkExpire - Source code

/**
 * Check if a cache object has expired
 *
 * Using @ error suppressor here because between if we did a file_exists() and then filemsize() there will
 * be a little time space when another process can delete the file and then you get PHP Warning
 *
 * @param   string  $id     Cache ID to check
 * @param   string  $group  The cache data group
 *
 * @return  boolean  True if the cache ID is valid
 *
 * @since   1.7.0
 */
protected function _checkExpire($id, $group)
{
    $path = $this->_getFilePath($id, $group);
    // Check prune period
    if (file_exists($path)) {
        $time = @filemtime($path);
        if ($time + $this->_lifetime < $this->_now || empty($time)) {
            File::invalidateFileCache($path);
            @unlink($path);
            return false;
        }
        // If, right now, the file does not exist then return false
        if (@filesize($path) == 0) {
            return false;
        }
        return true;
    }
    return false;
}