public function execute($limit = 0)
 {
     if ($this->executed) {
         return;
     }
     if ($limit) {
         $this->limit = $limit;
     }
     $microTimeStart = microtime(true);
     $renderer = KalturaSyndicationFeedFactory::getRendererByType($this->syndicationFeed->type);
     $renderer->init($this->syndicationFeed, $this->syndicationFeedDb, $this->mimeType);
     header($renderer->handleHttpHeader());
     echo $renderer->handleHeader();
     $cacheStore = null;
     if ($renderer->shouldEnableCache()) {
         $cacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_FEED_ENTRY);
     }
     $protocol = infraRequestUtils::getProtocol();
     $cachePrefix = "feed_{$this->syndicationFeed->id}/{$protocol}/entry_";
     $feedUpdatedAt = $this->syndicationFeedDb->getUpdatedAt(null);
     $e = null;
     $kalturaFeed = $this->syndicationFeed->type == KalturaSyndicationFeedType::KALTURA || $this->syndicationFeed->type == KalturaSyndicationFeedType::KALTURA_XSLT;
     $nextEntry = $this->getNextEntry();
     while ($nextEntry) {
         $this->enableApcProcessingFlag();
         $entry = $nextEntry;
         $nextEntry = $this->getNextEntry();
         // in case no video player is requested by user and the entry is mix, skip it
         if ($entry->getType() === entryType::MIX && !$this->syndicationFeed->allowEmbed) {
             continue;
         }
         $xml = false;
         // check cache
         $updatedAt = max($feedUpdatedAt, $entry->getUpdatedAt(null));
         if ($cacheStore) {
             $cacheKey = $cachePrefix . str_replace("_", "-", $entry->getId()) . self::CACHE_VERSION;
             // replace _ with - so cache folders will be created with random entry id and not 0_/1_
             $cacheTime = $cacheStore->get($cacheKey . self::CACHE_CREATION_TIME_SUFFIX);
             if ($cacheTime !== false && $cacheTime > $updatedAt + self::CACHE_CREATION_MARGIN) {
                 $xml = $cacheStore->get($cacheKey);
             }
         }
         if ($xml === false) {
             $e = null;
             if (!$kalturaFeed) {
                 $e = new KalturaMediaEntry();
                 $e->fromObject($entry);
             }
             $flavorAssetUrl = is_null($e) ? null : $this->getFlavorAssetUrl($e);
             if (!$kalturaFeed && $entry->getType() !== entryType::MIX && is_null($flavorAssetUrl)) {
                 $xml = "";
                 // cache empty result to avoid checking getFlavorAssetUrl next time
             } else {
                 $xml = $renderer->handleBody($entry, $e, $flavorAssetUrl);
             }
         }
         if ($cacheStore) {
             $cacheStore->set($cacheKey . self::CACHE_CREATION_TIME_SUFFIX, time(), self::CACHE_EXPIRY);
             $cacheStore->set($cacheKey, $xml, self::CACHE_EXPIRY);
         }
         echo $renderer->finalize($xml, $nextEntry !== false);
     }
     echo $renderer->handleFooter();
     if ($this->feedProcessingKey && function_exists('apc_delete')) {
         apc_delete($this->feedProcessingKey);
     }
     $microTimeEnd = microtime(true);
     KalturaLog::info("syndicationFeedRenderer- render time for ({$this->syndicationFeed->type}) is " . ($microTimeEnd - $microTimeStart));
 }