You are here

function apachesolr_views_plugin_cache_time::cache_get in Apache Solr Views 6

Retrieve data from the cache.

A plugin should override this to provide specialized caching behavior.

File

plugins/apachesolr_views_plugin_cache_time.inc, line 38
provides Views caching plugin for solr

Class

apachesolr_views_plugin_cache_time
@file provides Views caching plugin for solr

Code

function cache_get($type) {
  $cutoff = $this
    ->cache_expire($type);
  switch ($type) {
    case 'query':

      // Currently not supported in base class. but we send it up in case it is
      return parent::cache_get($type);
    case 'results':

      // Values to set: $view->result, $view->total_rows, $view->execute_time,
      // $view->pager['current_page'].
      if ($cache = cache_get($this
        ->get_results_key(), $this->table)) {
        if (!$cutoff || $cache->created > $cutoff) {
          $this->view->result = $cache->data['result'];
          $this->view->total_rows = $cache->data['total_rows'];
          $this->view->pager = $cache->data['pager'];
          apachesolr_static_response_cache($cache->data['response']);
          apachesolr_current_query($this->view->query);
          $this->view->execute_time = 0;
          apachesolr_has_searched(TRUE);
          return TRUE;
        }
      }
      return FALSE;
    case 'output':
      return parent::cache_get($type);
  }
}