本文整理汇总了PHP中Pimcore\Model\Cache::storeToCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::storeToCache方法的具体用法?PHP Cache::storeToCache怎么用?PHP Cache::storeToCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Cache
的用法示例。
在下文中一共展示了Cache::storeToCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadToCache
/**
* @param AbstractListing $list
*/
protected static function loadToCache(AbstractListing $list)
{
$totalCount = $list->getTotalCount();
$iterations = ceil($totalCount / self::getPerIteration());
\Logger::info("New list of elements queued for storing into the cache with " . $iterations . " iterations and " . $totalCount . " total items");
for ($i = 0; $i < $iterations; $i++) {
\Logger::info("Starting iteration " . $i . " with offset: " . self::getPerIteration() * $i);
$list->setLimit(self::getPerIteration());
$list->setOffset(self::getPerIteration() * $i);
$elements = $list->load();
foreach ($elements as $element) {
$cacheKey = Element\Service::getElementType($element) . "_" . $element->getId();
Cache::storeToCache($element, $cacheKey, [], null, null, true);
}
\Pimcore::collectGarbage();
sleep(self::getTimoutBetweenIteration());
}
}
示例2: loadElementToCache
/**
* Adds a Pimcore Object/Asset/Document to the cache
*
* @param $element
*/
public static function loadElementToCache($element)
{
$cacheKey = Element\Service::getElementType($element) . "_" . $element->getId();
Cache::storeToCache($element, $cacheKey, [], null, null, true);
}