Пример #1
0
 /**
  * @static
  * @param Pimcore_Model_List_Abstract $list
  * @return void
  */
 protected static function loadToCache(Pimcore_Model_List_Abstract $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();
             Pimcore_Model_Cache::storeToCache($element, $cacheKey);
         }
         Pimcore::collectGarbage();
         sleep(self::getTimoutBetweenIteration());
     }
 }
Пример #2
0
 public function getItems($offset, $itemCountPerPage)
 {
     parent::setOffset($offset);
     parent::setLimit($itemCountPerPage);
     return parent::load();
 }