0
- * This source file is subject to the new BSD license that is bundled
0
- * with this package in the file LICENSE.txt.
0
- * It is also available through the world-wide-web at this URL:
0
- * http://framework.zend.com/license/new-bsd
0
- * If you did not receive a copy of the license and are unable to
0
- * obtain it through the world-wide-web, please send an email
0
- * to license@zend.com so we can send you a copy immediately.
0
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
0
- * @license http://framework.zend.com/license/new-bsd New BSD License
0
- * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
0
- * @license http://framework.zend.com/license/new-bsd New BSD License
0
-class Zend_Cache_Backend
0
- * Frontend or Core directives
0
- * =====> (int) lifetime :
0
- * - Cache lifetime (in seconds)
0
- * - If null, the cache is valid forever
0
- * =====> (int) logging :
0
- * - if set to true, a logging is activated throw Zend_Log
0
- * @var array directives
0
- protected $_directives = array(
0
- * @var array available options
0
- protected $_options = array();
0
- // ----------------------
0
- // --- Public methods ---
0
- // ----------------------
0
- * @param array $options associative array of options
0
- public function __construct($options = array())
0
- if (!is_array($options)) Zend_Cache::throwException('Options parameter must be an array');
0
- while (list($name, $value) = each($options)) {
0
- $this->setOption($name, $value);
0
- * Set the frontend directives
0
- * @param array $directives assoc of directives
0
- public function setDirectives($directives)
0
- if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
0
- while (list($name, $value) = each($directives)) {
0
- if (!is_string($name)) {
0
- Zend_Cache::throwException("Incorrect option name : $name");
0
- $name = strtolower($name);
0
- if (array_key_exists($name, $this->_directives)) {
0
- $this->_directives[$name] = $value;
0
- $this->_loggerSanity();
0
- public function setOption($name, $value)
0
- if (!is_string($name)) {
0
- Zend_Cache::throwException("Incorrect option name : $name");
0
- $name = strtolower($name);
0
- if (!array_key_exists($name, $this->_options)) {
0
- Zend_Cache::throwException("Incorrect option name : $name");
0
- $this->_options[$name] = $value;
0
- * if $specificLifetime is not false, the given specific life time is used
0
- * else, the global lifetime is used
0
- * @return int cache life time
0
- public function getLifetime($specificLifetime)
0
- if ($specificLifetime === false) {
0
- return $this->_directives['lifetime'];
0
- return $specificLifetime;
0
- * Return true if the automatic cleaning is available for the backend
0
- public function isAutomaticCleaningAvailable()
0
- * Return a system-wide tmp directory
0
- * @return string system-wide tmp directory
0
- static function getTmpDir()
0
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
0
- foreach (array($_ENV, $_SERVER) as $tab) {
0
- foreach (array('TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
0
- if (isset($tab[$key])) {
0
- if (($key == 'windir') or ($key == 'SystemRoot')) {
0
- $result = $result . '\\temp';
0
- if (isset($_ENV['TMPDIR'])) return $_ENV['TMPDIR'];
0
- if (isset($_SERVER['TMPDIR'])) return $_SERVER['TMPDIR'];
0
- * Make sure if we enable logging that the Zend_Log class
0
- * Create a default log object if none is set.
0
- * @throws Zend_Cache_Exception
0
- protected function _loggerSanity()
0
- if (!isset($this->_directives['logging']) || !$this->_directives['logging']) {
0
- require_once 'Zend/Loader.php';
0
- Zend_Loader::loadClass('Zend_Log');
0
- } catch (Zend_Exception $e) {
0
- Zend_Cache::throwException('Logging feature is enabled but the Zend_Log class is not available');
0
- if (isset($this->_directives['logger']) && $this->_directives['logger'] instanceof Zend_Log) {
0
- // Create a default logger to the standard output stream
0
- Zend_Loader::loadClass('Zend_Log_Writer_Stream');
0
- $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
0
- $this->_directives['logger'] = $logger;
0
- * Log a message at the WARN (4) priority.
0
- * @param string $message
0
- * @throws Zend_Cache_Exception
0
- protected function _log($message, $priority = 4)
0
- if (!$this->_directives['logging']) {
0
- if (!(isset($this->_directives['logger']) || $this->_directives['logger'] instanceof Zend_Log)) {
0
- Zend_Cache::throwException('Logging is enabled but logger is not set');
0
- $logger = $this->_directives['logger'];
0
- $logger->log($message, $priority);