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) {
self::loadElementToCache($element);
}
\Pimcore::collectGarbage();
sleep(self::getTimoutBetweenIteration());
}
}