Exemplo n.º 1
0
 /**
  * @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());
     }
 }