/** * Constructor * * @param array $options associative array of options * @throws IfwPsn_Vendor_Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('wincache')) { IfwPsn_Vendor_Zend_Cache::throwException('The wincache extension must be loaded for using this backend !'); } parent::__construct($options); }
/** * Constructor * * @param array $options Associative array of options * @throws IfwPsn_Vendor_Zend_cache_Exception * @return void */ public function __construct(array $options = array()) { parent::__construct($options); if ($this->_options['cache_db_complete_path'] === null) { IfwPsn_Vendor_Zend_Cache::throwException('cache_db_complete_path option has to set'); } if (!extension_loaded('sqlite')) { IfwPsn_Vendor_Zend_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 IfwPsn_Vendor_Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!function_exists('accelerator_license_info')) { IfwPsn_Vendor_Zend_Cache::throwException('The Zend Platform extension must be loaded for using this backend !'); } if (!function_exists('accelerator_get_configuration')) { $licenseInfo = accelerator_license_info(); IfwPsn_Vendor_Zend_Cache::throwException('The Zend Platform extension is not loaded correctly: ' . $licenseInfo['failure_reason']); } $accConf = accelerator_get_configuration(); if (@(!$accConf['output_cache_licensed'])) { IfwPsn_Vendor_Zend_Cache::throwException('The Zend Platform extension does not have the proper license to use content caching features'); } if (@(!$accConf['output_cache_enabled'])) { IfwPsn_Vendor_Zend_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'])) { IfwPsn_Vendor_Zend_Cache::throwException('The cache copies directory \'' . ini_get('zend_accelerator.output_cache_dir') . '\' must be writable !'); } parent::__construct($options); }
/** * Constructor * * @param array $options associative array of options * @throws IfwPsn_Vendor_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'])) { IfwPsn_Vendor_Zend_Cache::throwException('Invalid file_name_prefix : must use only [a-zA-Z0-9_]'); } } if ($this->_options['metadatas_array_max_size'] < 10) { IfwPsn_Vendor_Zend_Cache::throwException('Invalid metadatas_array_max_size, must be > 10'); } if (isset($options['hashed_directory_umask'])) { // See #ZF-12047 trigger_error("'hashed_directory_umask' is deprecated -> please use 'hashed_directory_perm' instead", E_USER_NOTICE); if (!isset($options['hashed_directory_perm'])) { $options['hashed_directory_perm'] = $options['hashed_directory_umask']; } } if (isset($options['hashed_directory_perm']) && is_string($options['hashed_directory_perm'])) { // See #ZF-4422 $this->_options['hashed_directory_perm'] = octdec($this->_options['hashed_directory_perm']); } if (isset($options['cache_file_umask'])) { // See #ZF-12047 trigger_error("'cache_file_umask' is deprecated -> please use 'cache_file_perm' instead", E_USER_NOTICE); if (!isset($options['cache_file_perm'])) { $options['cache_file_perm'] = $options['cache_file_umask']; } } if (isset($options['cache_file_perm']) && is_string($options['cache_file_perm'])) { // See #ZF-4422 $this->_options['cache_file_perm'] = octdec($this->_options['cache_file_perm']); } }
/** * Constructor * * @param array $options associative array of options * @throws IfwPsn_Vendor_Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('memcache')) { IfwPsn_Vendor_Zend_Cache::throwException('The memcache extension must be loaded for using this backend !'); } parent::__construct($options); if (isset($this->_options['servers'])) { $value = $this->_options['servers']; if (isset($value['host'])) { // in this case, $value seems to be a simple associative array (one server only) $value = array(0 => $value); // let's transform it into a classical array of associative arrays } $this->setOption('servers', $value); } $this->_memcache = new Memcache(); foreach ($this->_options['servers'] as $server) { if (!array_key_exists('port', $server)) { $server['port'] = self::DEFAULT_PORT; } if (!array_key_exists('persistent', $server)) { $server['persistent'] = self::DEFAULT_PERSISTENT; } if (!array_key_exists('weight', $server)) { $server['weight'] = self::DEFAULT_WEIGHT; } if (!array_key_exists('timeout', $server)) { $server['timeout'] = self::DEFAULT_TIMEOUT; } if (!array_key_exists('retry_interval', $server)) { $server['retry_interval'] = self::DEFAULT_RETRY_INTERVAL; } if (!array_key_exists('status', $server)) { $server['status'] = self::DEFAULT_STATUS; } if (!array_key_exists('failure_callback', $server)) { $server['failure_callback'] = self::DEFAULT_FAILURE_CALLBACK; } if ($this->_options['compatibility']) { // No status for compatibility mode (#ZF-5887) $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], $server['weight'], $server['timeout'], $server['retry_interval']); } else { $this->_memcache->addServer($server['host'], $server['port'], $server['persistent'], $server['weight'], $server['timeout'], $server['retry_interval'], $server['status'], $server['failure_callback']); } } }
/** * Constructor * * @param array $options associative array of options * @throws IfwPsn_Vendor_Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('memcached')) { IfwPsn_Vendor_Zend_Cache::throwException('The memcached extension must be loaded for using this backend !'); } // override default client options $this->_options['client'] = array(Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT, Memcached::OPT_HASH => Memcached::HASH_MD5, Memcached::OPT_LIBKETAMA_COMPATIBLE => true); parent::__construct($options); if (isset($this->_options['servers'])) { $value = $this->_options['servers']; if (isset($value['host'])) { // in this case, $value seems to be a simple associative array (one server only) $value = array(0 => $value); // let's transform it into a classical array of associative arrays } $this->setOption('servers', $value); } $this->_memcache = new Memcached(); // setup memcached client options foreach ($this->_options['client'] as $name => $value) { $optId = null; if (is_int($name)) { $optId = $name; } else { $optConst = 'Memcached::OPT_' . strtoupper($name); if (defined($optConst)) { $optId = constant($optConst); } else { $this->_log("Unknown memcached client option '{$name}' ({$optConst})"); } } if ($optId) { if (!$this->_memcache->setOption($optId, $value)) { $this->_log("Setting memcached client option '{$optId}' failed"); } } } // setup memcached servers $servers = array(); foreach ($this->_options['servers'] as $server) { if (!array_key_exists('port', $server)) { $server['port'] = self::DEFAULT_PORT; } if (!array_key_exists('weight', $server)) { $server['weight'] = self::DEFAULT_WEIGHT; } $servers[] = array($server['host'], $server['port'], $server['weight']); } $this->_memcache->addServers($servers); }
/** * Constructor * * @param array $options Associative array of options * @throws IfwPsn_Vendor_Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { parent::__construct($options); if ($this->_options['slow_backend'] === null) { IfwPsn_Vendor_Zend_Cache::throwException('slow_backend option has to set'); } elseif ($this->_options['slow_backend'] instanceof IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface) { $this->_slowBackend = $this->_options['slow_backend']; } else { $this->_slowBackend = IfwPsn_Vendor_Zend_Cache::_makeBackend($this->_options['slow_backend'], $this->_options['slow_backend_options'], $this->_options['slow_backend_custom_naming'], $this->_options['slow_backend_autoload']); if (!in_array('IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface', class_implements($this->_slowBackend))) { IfwPsn_Vendor_Zend_Cache::throwException('slow_backend must implement the IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface interface'); } } if ($this->_options['fast_backend'] === null) { IfwPsn_Vendor_Zend_Cache::throwException('fast_backend option has to set'); } elseif ($this->_options['fast_backend'] instanceof IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface) { $this->_fastBackend = $this->_options['fast_backend']; } else { $this->_fastBackend = IfwPsn_Vendor_Zend_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('IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface', class_implements($this->_fastBackend))) { IfwPsn_Vendor_Zend_Cache::throwException('fast_backend must implement the IfwPsn_Vendor_Zend_Cache_Backend_ExtendedInterface interface'); } } $this->_slowBackend->setDirectives($this->_directives); $this->_fastBackend->setDirectives($this->_directives); }