Skip to content
Snippets Groups Projects
Commit 6f599b02 authored by Demian Katz's avatar Demian Katz
Browse files

Added channel home page caching.

parent 23434510
No related merge requests found
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
; this section controls which source will be used: ; this section controls which source will be used:
default_home_source = "Solr" 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. ; 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 ; 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 ; to use. If no configuration section is provided, the default of
......
...@@ -85,7 +85,23 @@ class ChannelsController extends AbstractBase ...@@ -85,7 +85,23 @@ class ChannelsController extends AbstractBase
$providers = $this->getChannelProviderArray($providerIds, $config); $providers = $this->getChannelProviderArray($providerIds, $config);
$token = $this->params()->fromQuery('channelToken'); $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')); return $this->createViewModel(compact('token', 'channels'));
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment