web/lib/Zend/Cache/Backend.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Cache
    16  * @package    Zend_Cache
    17  * @subpackage Zend_Cache_Backend
    17  * @subpackage Zend_Cache_Backend
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Backend.php 20880 2010-02-03 18:18:32Z matthew $
    20  * @version    $Id: Backend.php 24989 2012-06-21 07:24:13Z mabe $
    21  */
    21  */
    22 
    22 
    23 
    23 
    24 /**
    24 /**
    25  * @package    Zend_Cache
    25  * @package    Zend_Cache
    26  * @subpackage Zend_Cache_Backend
    26  * @subpackage Zend_Cache_Backend
    27  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    27  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    28  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    28  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    29  */
    29  */
    30 class Zend_Cache_Backend
    30 class Zend_Cache_Backend
    31 {
    31 {
    32     /**
    32     /**
   110             $this->_options[$name] = $value;
   110             $this->_options[$name] = $value;
   111         }
   111         }
   112     }
   112     }
   113 
   113 
   114     /**
   114     /**
       
   115      * Returns an option
       
   116      *
       
   117      * @param string $name Optional, the options name to return
       
   118      * @throws Zend_Cache_Exceptions
       
   119      * @return mixed
       
   120      */
       
   121     public function getOption($name)
       
   122     {
       
   123         $name = strtolower($name);
       
   124 
       
   125         if (array_key_exists($name, $this->_options)) {
       
   126             return $this->_options[$name];
       
   127         }
       
   128 
       
   129         if (array_key_exists($name, $this->_directives)) {
       
   130             return $this->_directives[$name];
       
   131         }
       
   132 
       
   133         Zend_Cache::throwException("Incorrect option name : {$name}");
       
   134     }
       
   135 
       
   136     /**
   115      * Get the life time
   137      * Get the life time
   116      *
   138      *
   117      * if $specificLifetime is not false, the given specific life time is used
   139      * if $specificLifetime is not false, the given specific life time is used
   118      * else, the global lifetime is used
   140      * else, the global lifetime is used
   119      *
   141      *
   152     public function getTmpDir()
   174     public function getTmpDir()
   153     {
   175     {
   154         $tmpdir = array();
   176         $tmpdir = array();
   155         foreach (array($_ENV, $_SERVER) as $tab) {
   177         foreach (array($_ENV, $_SERVER) as $tab) {
   156             foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
   178             foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key) {
   157                 if (isset($tab[$key])) {
   179                 if (isset($tab[$key]) && is_string($tab[$key])) {
   158                     if (($key == 'windir') or ($key == 'SystemRoot')) {
   180                     if (($key == 'windir') or ($key == 'SystemRoot')) {
   159                         $dir = realpath($tab[$key] . '\\temp');
   181                         $dir = realpath($tab[$key] . '\\temp');
   160                     } else {
   182                     } else {
   161                         $dir = realpath($tab[$key]);
   183                         $dir = realpath($tab[$key]);
   162                     }
   184                     }
   198     }
   220     }
   199 
   221 
   200     /**
   222     /**
   201      * Verify if the given temporary directory is readable and writable
   223      * Verify if the given temporary directory is readable and writable
   202      *
   224      *
   203      * @param $dir temporary directory
   225      * @param string $dir temporary directory
   204      * @return boolean true if the directory is ok
   226      * @return boolean true if the directory is ok
   205      */
   227      */
   206     protected function _isGoodTmpDir($dir)
   228     protected function _isGoodTmpDir($dir)
   207     {
   229     {
   208         if (is_readable($dir)) {
   230         if (is_readable($dir)) {
   235         }
   257         }
   236 
   258 
   237         // Create a default logger to the standard output stream
   259         // Create a default logger to the standard output stream
   238         require_once 'Zend/Log.php';
   260         require_once 'Zend/Log.php';
   239         require_once 'Zend/Log/Writer/Stream.php';
   261         require_once 'Zend/Log/Writer/Stream.php';
       
   262         require_once 'Zend/Log/Filter/Priority.php';
   240         $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
   263         $logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
       
   264         $logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
   241         $this->_directives['logger'] = $logger;
   265         $this->_directives['logger'] = $logger;
   242     }
   266     }
   243 
   267 
   244     /**
   268     /**
   245      * Log a message at the WARN (4) priority.
   269      * Log a message at the WARN (4) priority.