public function refreshFeed() : array
 {
     $cacheId = $this->blogOptions->getCacheKey();
     $feed = Reader::import($this->blogOptions->getFeed());
     $feed = $this->processFeed($feed);
     // If no feed has been cached yet, cache current one and return
     if (!$this->feedCache->contains($cacheId)) {
         $this->templatesCache->deleteAll();
         $this->feedCache->save($cacheId, $feed);
         return $feed;
     }
     // Check if the last feed has changed, otherwise, return
     $cachedFeed = $this->feedCache->fetch($cacheId);
     if ($cachedFeed[0]['link'] === $feed[0]['link']) {
         return $feed;
     }
     // If the feed has changed, clear all cached elements so that views are refreshed, and cache feed too
     $this->templatesCache->deleteAll();
     $this->feedCache->save($cacheId, $feed);
     return $feed;
 }
 function it_deletes_all_elements_if_cache_is_clearable(ClearableCache $cache)
 {
     $cache->deleteAll()->shouldBeCalled();
     $this->clear(null);
 }
Ejemplo n.º 3
0
 /**
  * @param LifecycleEventArgs $args
  */
 protected function clearCache(LifecycleEventArgs $args)
 {
     if ($args->getObject() instanceof RoleInterface || $args->getObject() instanceof PermissionInterface) {
         $this->cache->deleteAll();
     }
 }