diff --git a/config/vufind/channels.ini b/config/vufind/channels.ini index ec6ffc605fb19257b51218ef57688a22de1b3abb..f6af7eef6453b1291db566db49cbf1bc63a63a5f 100644 --- a/config/vufind/channels.ini +++ b/config/vufind/channels.ini @@ -6,6 +6,9 @@ ; this section controls which source will be used: default_home_source = "Solr" +; Should we cache channel results on the Channels/Home screen? +cache_home_channels = true + ; This section controls which providers are used for Solr searches/records. ; Providers may be followed by a colon and the name of a configuration section ; to use. If no configuration section is provided, the default of diff --git a/module/VuFind/src/VuFind/Controller/ChannelsController.php b/module/VuFind/src/VuFind/Controller/ChannelsController.php index 420522eee143993f84a306db6e84c19861008e65..44ac183261d982e66fe669e2aaa229685f4e23ae 100644 --- a/module/VuFind/src/VuFind/Controller/ChannelsController.php +++ b/module/VuFind/src/VuFind/Controller/ChannelsController.php @@ -85,7 +85,23 @@ class ChannelsController extends AbstractBase $providers = $this->getChannelProviderArray($providerIds, $config); $token = $this->params()->fromQuery('channelToken'); - $channels = $this->getHomeChannels($providers, $searchClassId, $token); + if (isset($config->General->cache_home_channels) + && $config->General->cache_home_channels + ) { + $parts = implode('-', [implode(',', $providerIds), $searchClassId, $token]); + $cacheKey = 'homeChannels-' . md5($parts); + $cache = $this->serviceLocator->get('VuFind\CacheManager') + ->getCache('object'); + } else { + $cacheKey = false; + } + $channels = $cacheKey ? $cache->getItem($cacheKey) : false; + if (!$channels) { + $channels = $this->getHomeChannels($providers, $searchClassId, $token); + if ($cacheKey) { + $cache->setItem($cacheKey, $channels); + } + } return $this->createViewModel(compact('token', 'channels')); }