Pimcore\Cache::addClearedTag PHP Method

addClearedTag() public static method

public static addClearedTag ( string $tag )
$tag string
    public static function addClearedTag($tag)
    {
        self::$clearedTagsStack[] = $tag;
    }

Usage Example

Beispiel #1
0
 /**
  *
  */
 public function dispatchLoopShutdown()
 {
     if ($this->enabled && session_id()) {
         $this->disable("session in use");
     }
     if ($this->disableReason) {
         $this->getResponse()->setHeader("X-Pimcore-Output-Cache-Disable-Reason", $this->disableReason, true);
     }
     if ($this->enabled && $this->getResponse()->getHttpResponseCode() == 200) {
         try {
             if ($this->lifetime && $this->addExpireHeader) {
                 // add cache control for proxies and http-caches like varnish, ...
                 $this->getResponse()->setHeader("Cache-Control", "public, max-age=" . $this->lifetime, true);
                 // add expire header
                 $date = new \DateTime("now");
                 $date->add(new \DateInterval("PT" . $this->lifetime . "S"));
                 $this->getResponse()->setHeader("Expires", $date->format(\DateTime::RFC1123), true);
             }
             $now = new \DateTime("now");
             $cacheItem = ["headers" => $this->getResponse()->getHeaders(), "rawHeaders" => $this->getResponse()->getRawHeaders(), "content" => $this->getResponse()->getBody(), "date" => $now->format(\DateTime::ISO8601)];
             $cacheKey = $this->defaultCacheKey;
             $deviceDetector = Tool\DeviceDetector::getInstance();
             if ($deviceDetector->wasUsed()) {
                 $cacheKey .= "_" . $deviceDetector->getDevice();
             }
             CacheManager::save($cacheItem, $cacheKey, ["output"], $this->lifetime, 1000);
         } catch (\Exception $e) {
             \Logger::error($e);
             return;
         }
     } else {
         // output-cache was disabled, add "output" as cleared tag to ensure that no other "output" tagged elements
         // like the inc and snippet cache get into the cache
         CacheManager::addClearedTag("output_inline");
     }
 }
All Usage Examples Of Pimcore\Cache::addClearedTag