本文整理汇总了PHP中Pimcore\Cache::addClearedTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::addClearedTag方法的具体用法?PHP Cache::addClearedTag怎么用?PHP Cache::addClearedTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Cache
的用法示例。
在下文中一共展示了Cache::addClearedTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchLoopShutdown
/**
*
*/
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");
}
}
示例2: loadChilds
/**
* @param Element\ElementInterface $element
*/
public function loadChilds(Element\ElementInterface $element)
{
$this->amount++;
Element\Service::loadAllFields($element);
// for all
$element->getProperties();
if (method_exists($element, "getScheduledTasks")) {
$element->getScheduledTasks();
}
$element->_fulldump = true;
// we need to add the tag of each item to the cache cleared stack, so that the item doesn't gets into the cache
// with the property _fulldump set, because this would cause major issues in wakeUp()
\Pimcore\Cache::addClearedTag($element->getCacheTag());
if (method_exists($element, "getChilds")) {
if ($element instanceof Object\AbstractObject) {
// because we also want variants
$childs = $element->getChilds(array(Object::OBJECT_TYPE_FOLDER, Object::OBJECT_TYPE_VARIANT, Object::OBJECT_TYPE_OBJECT));
} else {
$childs = $element->getChilds();
}
foreach ($childs as $child) {
$this->loadChilds($child);
}
}
}