예제 #1
0
파일: CoreTest.php 프로젝트: rexmac/zf2
 /**
  * @group ZF-9092
  */
 public function testSettingLifetimeAsEmptyIsInterpretedAsNull()
 {
     $config = new ZendConfig(array('lifetime' => '', 'caching' => true));
     $test = new Cache\Frontend\Core();
     $test->setConfig($config);
     $this->assertSame(NULL, $test->getOption('lifetime'));
 }
예제 #2
0
 /**
  * Return controllers modification info from the cache
  * @return array 
  */
 protected function _getControllersCache()
 {
     $controllers = array();
     if ($this->cache->hasItem('controllers')) {
         $controllers = (array) unserialize($this->cache->getItem('controllers'));
     }
     return $controllers;
 }
예제 #3
0
 /**
  * Returns the page item cache.
  *
  * @return array
  */
 public function getPageItemCache()
 {
     $data = array();
     if ($this->_cacheEnabled()) {
         foreach (self::$_cache->getIdsMatchingTags(array($this->_getCacheInternalId())) as $id) {
             if (preg_match('|' . self::CACHE_TAG_PREFIX . "(\\d+)_.*|", $id, $page)) {
                 $data[$page[1]] = self::$_cache->load($this->_getCacheId($page[1]));
             }
         }
     }
     return $data;
 }
예제 #4
0
파일: Output.php 프로젝트: hjr3/zf2
 /**
  * Constructor
  *
  * @param  array $options Associative array of options
  * @return void
  */
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     $this->_idStack = array();
 }
예제 #5
0
파일: AbstractTable.php 프로젝트: hjr3/zf2
 /**
  * Initializes metadata.
  *
  * If metadata cannot be loaded from cache, adapter's describeTable() method is called to discover metadata
  * information. Returns true if and only if the metadata are loaded from cache.
  *
  * @return boolean
  * @throws \Zend\DB\Table\Exception
  */
 protected function _setupMetadata()
 {
     if ($this->metadataCacheInClass() && count($this->_metadata) > 0) {
         return true;
     }
     // Assume that metadata will be loaded from cache
     $isMetadataFromCache = true;
     // If $this has no metadata cache but the class has a default metadata cache
     if (null === $this->_metadataCache && null !== self::$_defaultMetadataCache) {
         // Make $this use the default metadata cache of the class
         $this->_setMetadataCache(self::$_defaultMetadataCache);
     }
     // If $this has a metadata cache
     if (null !== $this->_metadataCache) {
         // Define the cache identifier where the metadata are saved
         //get db configuration
         $dbConfig = $this->_db->getConfig();
         // Define the cache identifier where the metadata are saved
         $cacheId = md5((isset($dbConfig['options']['port']) ? ':' . $dbConfig['options']['port'] : null) . (isset($dbConfig['options']['host']) ? ':' . $dbConfig['options']['host'] : null) . '/' . $dbConfig['dbname'] . ':' . $this->_schema . '.' . $this->_name);
     }
     // If $this has no metadata cache or metadata cache misses
     if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) {
         // Metadata are not loaded from cache
         $isMetadataFromCache = false;
         // Fetch metadata from the adapter's describeTable() method
         $metadata = $this->_db->describeTable($this->_name, $this->_schema);
         // If $this has a metadata cache, then cache the metadata
         if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) {
             trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE);
         }
     }
     // Assign the metadata to $this
     $this->_metadata = $metadata;
     // Return whether the metadata were loaded from cache
     return $isMetadataFromCache;
 }
예제 #6
0
파일: File.php 프로젝트: rexmac/zf2
 /**
  * Test if a cache is available for the given id
  *
  * @param  string $id Cache id
  * @return int|false Last modified time of cache entry if it is available, false otherwise
  */
 public function test($id)
 {
     $lastModified = parent::test($id);
     if ($lastModified) {
         if ($this->_specificOptions['master_files_mode'] == self::MODE_AND) {
             // MODE_AND
             foreach ($this->_masterFile_mtimes as $masterFileMTime) {
                 if ($masterFileMTime) {
                     if ($lastModified > $masterFileMTime) {
                         return $lastModified;
                     }
                 }
             }
         } else {
             // MODE_OR
             $res = true;
             foreach ($this->_masterFile_mtimes as $masterFileMTime) {
                 if ($masterFileMTime) {
                     if ($lastModified <= $masterFileMTime) {
                         return false;
                     }
                 }
             }
             return $lastModified;
         }
     }
     return false;
 }
예제 #7
0
 /**
  * Public frontend to set an option
  *
  * Just a wrapper to get a specific behaviour for cached_entity
  *
  * @param  string $name  Name of the option
  * @param  mixed  $value Value of the option
  * @throws \Zend\Cache\Exception
  * @return void
  */
 public function setOption($name, $value)
 {
     if ($name == 'cached_entity') {
         $this->setCachedEntity($value);
     } else {
         parent::setOption($name, $value);
     }
 }
예제 #8
0
파일: Adapter.php 프로젝트: hjr3/zf2
 /**
  * Clears all set cache data
  *
  * @return void
  */
 public static function clearCache()
 {
     self::$_cache->clean(\Zend\Cache\Cache::CLEANING_MODE_MATCHING_TAG, array('Zend_Translate'));
 }