Back to CacheStorage class

Method __construct

public
__construct
(mixed $options = array())
Constructor
Parameters
  • array $options Optional parameters
Since
  • 1.7.0
Class: CacheStorage
Project: Joomla

Method __construct - Source code

/**
 * Constructor
 *
 * @param   array  $options  Optional parameters
 *
 * @since   1.7.0
 */
public function __construct($options = array())
{
    $app = Factory::getApplication();
    $this->_hash = md5($app->get('secret'));
    $this->_application = $options['application'] ?? md5(JPATH_CONFIGURATION);
    $this->_language = $options['language'] ?? 'en-GB';
    $this->_locking = $options['locking'] ?? true;
    $this->_lifetime = ($options['lifetime'] ?? $app->get('cachetime')) * 60;
    $this->_now = $options['now'] ?? time();
    // Set time threshold value.  If the lifetime is not set, default to 60 (0 is BAD)
    // _threshold is now available ONLY as a legacy (it's deprecated).  It's no longer used in the core.
    if (empty($this->_lifetime)) {
        $this->_threshold = $this->_now - 60;
        $this->_lifetime = 60;
    } else {
        $this->_threshold = $this->_now - $this->_lifetime;
    }
}