Back to FileStorage class

Method get

public mixed
get
(mixed $id, mixed $group, mixed $checkTime = true)
Get cached data by ID and group
Parameters
  • string $id The cache data ID
  • string $group The cache data group
  • bool $checkTime True to verify cache time expiration threshold
Returns
  • mixed Boolean false on failure or a cached data object
Since
  • 1.7.0
Class: FileStorage
Project: Joomla

Method get - Source code

/**
 * Get cached data by ID and group
 *
 * @param   string   $id         The cache data ID
 * @param   string   $group      The cache data group
 * @param   boolean  $checkTime  True to verify cache time expiration threshold
 *
 * @return  mixed  Boolean false on failure or a cached data object
 *
 * @since   1.7.0
 */
public function get($id, $group, $checkTime = true)
{
    $path = $this->_getFilePath($id, $group);
    $close = false;
    if ($checkTime == false || $checkTime == true && $this->_checkExpire($id, $group) === true) {
        if (file_exists($path)) {
            if (isset($this->_locked_files[$path])) {
                $_fileopen = $this->_locked_files[$path];
            } else {
                $_fileopen = @fopen($path, 'rb');
                // There is no lock, we have to close file after store data
                $close = true;
            }
            if ($_fileopen) {
                // On Windows system we can not use file_get_contents on the file locked by yourself
                $data = stream_get_contents($_fileopen);
                if ($close) {
                    @fclose($_fileopen);
                }
                if ($data !== false) {
                    // Remove the initial die() statement
                    return str_replace('<?php die("Access Denied"); ?>#x#', '', $data);
                }
            }
        }
    }
    return false;
}