Ejemplo n.º 1
0
 function endDataCache($vars = false)
 {
     if (!$this->isStarted) {
         return;
     }
     $this->isStarted = false;
     $arAllVars = array("CONTENT" => ob_get_contents(), "VARS" => $vars !== false ? $vars : $this->vars);
     $this->cacheEngine->write($arAllVars, $this->baseDir, $this->initDir, $this->filename, $this->TTL);
     if (static::$showCacheStat) {
         $written = 0;
         $path = '';
         if ($this->cacheEngine instanceof ICacheEngineStat) {
             $written = $this->cacheEngine->getWrittenBytes();
             $path = $this->cacheEngine->getCachePath();
         } elseif ($this->cacheEngine instanceof \ICacheBackend) {
             /** @noinspection PhpUndefinedFieldInspection */
             $written = $this->cacheEngine->written;
             /** @noinspection PhpUndefinedFieldInspection */
             $path = $this->cacheEngine->path;
         }
         Diag\CacheTracker::addCacheStatBytes($written);
         Diag\CacheTracker::add($written, $path, $this->baseDir, $this->initDir, $this->filename, "W");
     }
     if (strlen(ob_get_contents()) > 0) {
         ob_end_flush();
     } else {
         ob_end_clean();
     }
 }
Ejemplo n.º 2
0
 function EndDataCache()
 {
     if (!$this->bStarted) {
         return;
     }
     $this->bStarted = false;
     $arAllVars = ob_get_contents();
     $this->_cache->write($arAllVars, $this->basedir, $this->initdir, $this->filename, $this->TTL);
     if (\Bitrix\Main\Data\Cache::getShowCacheStat()) {
         $written = 0;
         $path = '';
         if ($this->_cache instanceof \Bitrix\Main\Data\ICacheEngineStat) {
             $written = $this->_cache->getWrittenBytes();
             $path = $this->_cache->getCachePath();
         } elseif ($this->_cache instanceof \ICacheBackend) {
             /** @noinspection PhpUndefinedFieldInspection */
             $written = $this->_cache->written;
             /** @noinspection PhpUndefinedFieldInspection */
             $path = $this->_cache->path;
         }
         \Bitrix\Main\Diag\CacheTracker::addCacheStatBytes($written);
         \Bitrix\Main\Diag\CacheTracker::add($written, $path, $this->basedir, $this->initdir, $this->filename, "W");
     }
     if (strlen($arAllVars) > 0) {
         ob_end_flush();
     } else {
         ob_end_clean();
     }
 }