コード例 #1
0
 public function setStrategyCache(WidgetEvent $event)
 {
     $widget = $event->getWidget();
     $cacheOptions = $event->getStrategy()->getCacheOptions($widget);
     // Set options on response
     $event->getResponse()->setCache($cacheOptions);
 }
コード例 #2
0
 /**
  * Sets the TTL on widget cache after the other cache options have been set,
  * this allows us to make sure widgets refresh every so often regardless.
  *
  * @param WidgetEvent $event
  */
 public function setSharedCache(WidgetEvent $event)
 {
     // Not cacheable, don't add anything
     if (!$event->getResponse()->isCacheable()) {
         return;
     }
     $advancedSettings = $this->settings->load('advanced');
     $ttl = $advancedSettings->get('widget_max_age');
     // Set max lifetime for widgets
     $event->getResponse()->setSharedMaxAge($ttl);
 }