Exemple #1
0
 public function load($id, $doNotTestCacheValidity = false, $doNotUnserialize = false)
 {
     if (!$this->_options['caching']) {
         return false;
     }
     $data = parent::load($id, $doNotTestCacheValidity, $doNotUnserialize);
     Centurion_Cache_TagManager::start($id, $this, $data, false);
     return $data;
 }
Exemple #2
0
 /**
  * Start the cache
  *
  * @param  string  $id                     Cache id
  * @param  boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
  * @param  boolean $echoData               If set to true, datas are sent to the browser if the cache is hit (simpy returned else)
  * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas)
  */
 public function start($id, array $tags, $extension = null)
 {
     parent::start($id, $tags, $extension);
     Centurion_Cache_TagManager::start($id, $this, false);
     return false;
 }
Exemple #3
0
 /**
  * Start the cache
  *
  * @param  string  $id       (optional) A cache id (if you set a value here, maybe you have to use Output frontend instead)
  * @param  boolean $doNotDie For unit testing only !
  * @return boolean True if the cache is hit (false else)
  */
 public function start($id = false, $doNotDie = false)
 {
     $this->_cancel = false;
     $lastMatchingRegexp = null;
     foreach ($this->_specificOptions['regexps'] as $regexp => $conf) {
         if (preg_match("`{$regexp}`", $_SERVER['REQUEST_URI'])) {
             $lastMatchingRegexp = $regexp;
         }
     }
     $this->_activeOptions = $this->_specificOptions['default_options'];
     if ($lastMatchingRegexp !== null) {
         $conf = $this->_specificOptions['regexps'][$lastMatchingRegexp];
         foreach ($conf as $key => $value) {
             $this->_activeOptions[$key] = $value;
         }
     }
     if (!$this->_activeOptions['cache']) {
         return false;
     }
     if (!$id) {
         $id = $this->_makeId();
         if (!$id) {
             return false;
         }
     }
     $array = $this->load($id);
     if ($array !== false) {
         $data = $array['data'];
         $headers = $array['headers'];
         $noDebug = false;
         if (!headers_sent()) {
             foreach ($headers as $key => $headerCouple) {
                 $name = $headerCouple[0];
                 $value = $headerCouple[1];
                 if ($name == 'Content-Type') {
                     $noDebug = true;
                 }
                 header("{$name}: {$value}");
             }
         }
         if (!$noDebug && $this->_specificOptions['debug_header']) {
             echo 'DEBUG HEADER : This is a cached page !';
         }
         echo $data;
         if (!$noDebug && $this->_specificOptions['debug_footer']) {
             $metadata = $this->getMetadatas($id);
             $dateCreated = new Zend_Date($metadata['mtime']);
             $dateExpire = new Zend_Date($metadata['expire']);
             echo '<!-- Page in cache since: ' . $dateCreated->toString(Zend_Date::DATETIME_LONG) . ' -->' . "\n";
             echo '<!-- Will expire at: ' . $dateExpire->toString(Zend_Date::DATETIME_LONG) . ' -->' . "\n";
             //echo '<!-- With tag: ' . print_r($metadata['tags'], true) . ' -->';
         }
         if ($doNotDie) {
             return true;
         }
         die;
     }
     ob_start(array($this, '_flush'));
     ob_implicit_flush(false);
     if (true === $this->_activeOptions['cache'] && (false !== $id || $this->_makeId())) {
         Centurion_Cache_TagManager::start(false !== $id ? $id : $this->_makeId(), $this, false);
     }
     return false;
 }
Exemple #4
0
 /**
  * Start the cache
  *
  * @param  string  $id                     Cache id
  * @param  boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
  * @param  boolean $echoData               If set to true, datas are sent to the browser if the cache is hit (simpy returned else)
  * @return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas)
  */
 public function start($id, $doNotTestCacheValidity = false, $echoData = true)
 {
     $data = parent::start($id, $doNotTestCacheValidity, $echoData);
     Centurion_Cache_TagManager::start($id, $this, $data);
     return $data;
 }