/** * Constructor * * @param array $options associative array of options * @throws \Zend\Cache\Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('xcache')) { Cache\Cache::throwException('The xcache extension must be loaded for using this backend !'); } parent::__construct($options); }
/** * Constructor * * @param array $options Associative array of options * @throws Zend_cache_Exception * @return void */ public function __construct(array $options = array()) { parent::__construct($options); if ($this->_options['cache_db_complete_path'] === null) { Cache\Cache::throwException('cache_db_complete_path option has to set'); } if (!extension_loaded('sqlite')) { Cache\Cache::throwException("Cannot use SQLite storage because the 'sqlite' extension is not loaded in the current PHP environment"); } $this->_getConnection(); }
/** * Constructor * Validate that the Zend Platform is loaded and licensed * * @param array $options Associative array of options * @throws \Zend\Cache\Exception * @return void */ public function __construct(array $options = array()) { if (!function_exists('accelerator_license_info')) { Cache\Cache::throwException('The Zend Platform extension must be loaded for using this backend !'); } if (!function_exists('accelerator_get_configuration')) { $licenseInfo = accelerator_license_info(); Cache\Cache::throwException('The Zend Platform extension is not loaded correctly: ' . $licenseInfo['failure_reason']); } $accConf = accelerator_get_configuration(); if (@(!$accConf['output_cache_licensed'])) { Cache\Cache::throwException('The Zend Platform extension does not have the proper license to use content caching features'); } if (@(!$accConf['output_cache_enabled'])) { Cache\Cache::throwException('The Zend Platform content caching feature must be enabled for using this backend, set the \'zend_accelerator.output_cache_enabled\' directive to On !'); } if (!is_writable($accConf['output_cache_dir'])) { Cache\Cache::throwException('The cache copies directory \'' . ini_get('zend_accelerator.output_cache_dir') . '\' must be writable !'); } parent::__construct($options); }
/** * Set the frontend directives * * @param array $directives Assoc of directives * @throws \Zend\Cache\Exception * @return void */ public function setDirectives($directives) { parent::setDirectives($directives); $lifetime = $this->getLifetime(false); if ($lifetime > 2592000) { // #ZF-3490 : For the memcached backend, there is a lifetime limit of 30 days (2592000 seconds) $this->_log('memcached backend has a limit of 30 days (2592000 seconds) for the lifetime'); } if ($lifetime === null) { // #ZF-4614 : we tranform null to zero to get the maximal lifetime parent::setDirectives(array('lifetime' => 0)); } }
/** * Retrieve any option via interception of the parent's statically held * options including the local option for a tag cache. * * @param string $name * @return mixed */ public function getOption($name) { if ($name == 'tag_cache') { return $this->getInnerCache(); } else { if (in_array($name, $this->_options)) { return $this->_options[$name]; } if ($name == 'lifetime') { return parent::getLifetime(); } return null; } }
/** * Constructor * * @param array $options associative array of options * @throws \Zend\Cache\Exception * @return void */ public function __construct(array $options = array()) { parent::__construct($options); if ($this->_options['cache_dir'] !== null) { // particular case for this option $this->setCacheDir($this->_options['cache_dir']); } else { $this->setCacheDir(self::getTmpDir() . DIRECTORY_SEPARATOR, false); } if (isset($this->_options['file_name_prefix'])) { // particular case for this option if (!preg_match('~^[a-zA-Z0-9_]+$~D', $this->_options['file_name_prefix'])) { Cache\Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]'); } } if ($this->_options['metadatas_array_max_size'] < 10) { Cache\Cache::throwException('Invalid metadatas_array_max_size, must be > 10'); } if (isset($options['hashed_directory_umask']) && is_string($options['hashed_directory_umask'])) { // See #ZF-4422 $this->_options['hashed_directory_umask'] = octdec($this->_options['hashed_directory_umask']); } if (isset($options['cache_file_umask']) && is_string($options['cache_file_umask'])) { // See #ZF-4422 $this->_options['cache_file_umask'] = octdec($this->_options['cache_file_umask']); } }
/** * Constructor * * @param array $options Associative array of options * @throws \Zend\Cache\Exception * @return void */ public function __construct(array $options = array()) { parent::__construct($options); if ($this->_options['slow_backend'] === null) { Cache\Cache::throwException('slow_backend option has to set'); } if ($this->_options['fast_backend'] === null) { Cache\Cache::throwException('fast_backend option has to set'); } $this->_slowBackend = Cache\Cache::_makeBackend($this->_options['slow_backend'], $this->_options['slow_backend_options'], $this->_options['slow_backend_custom_naming'], $this->_options['slow_backend_autoload']); $this->_fastBackend = Cache\Cache::_makeBackend($this->_options['fast_backend'], $this->_options['fast_backend_options'], $this->_options['fast_backend_custom_naming'], $this->_options['fast_backend_autoload']); if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) { Cache\Cache::throwException('slow_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); } if (!in_array('Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) { Cache\Cache::throwException('fast_backend must implement the Zend_Cache_Backend_ExtendedInterface interface'); } $this->_slowBackend->setDirectives($this->_directives); $this->_fastBackend->setDirectives($this->_directives); }
/** * Retrieve any option via interception of the parent's statically held * options including the local option for a tag cache. * * @param string $name * @return mixed */ public function getOption($name = array()) { if ($name == 'tag_cache') { return $this->getInnerCache(); } else if ($name == 'lifetime') { return parent::getLifetime(); } return parent::getOption($name); }