You are here

class views_plugin_cache_time in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 plugins/views_plugin_cache_time.inc \views_plugin_cache_time
  2. 7.3 plugins/views_plugin_cache_time.inc \views_plugin_cache_time

Simple caching of query results for Views displays.

Hierarchy

Expanded class hierarchy of views_plugin_cache_time

1 string reference to 'views_plugin_cache_time'
views_views_plugins in includes/plugins.inc
Implementation of hook_views_plugins

File

plugins/views_plugin_cache_time.inc, line 6

View source
class views_plugin_cache_time extends views_plugin_cache {
  function option_defaults(&$options) {
    $options['results_lifespan'] = 3600;
    $options['output_lifespan'] = 3600;
  }
  function options_form(&$form, &$form_state) {
    $options = array(
      60,
      300,
      1800,
      3600,
      21600,
      518400,
    );
    $options = drupal_map_assoc($options, 'format_interval');
    $options = array(
      -1 => t('Never cache'),
    ) + $options;
    $form['results_lifespan'] = array(
      '#type' => 'select',
      '#title' => t('Query results'),
      '#description' => t('The length of time raw query results should be cached.'),
      '#options' => $options,
      '#default_value' => $this->options['results_lifespan'],
    );
    $form['output_lifespan'] = array(
      '#type' => 'select',
      '#title' => t('Rendered output'),
      '#description' => t('The length of time rendered HTML output should be cached.'),
      '#options' => $options,
      '#default_value' => $this->options['output_lifespan'],
    );
  }
  function summary_title() {
    return format_interval($this->options['results_lifespan'], 1) . '/' . format_interval($this->options['output_lifespan'], 1);
  }
  function cache_expire($type) {
    if ($lifespan = $this->options[$type . '_lifespan']) {
      $cutoff = time() - $lifespan;
      return $cutoff;
    }
    else {
      return FALSE;
    }
  }
  function cache_set_expire($type) {
    if ($lifespan = $this->options[$type . '_lifespan']) {
      return time() + $lifespan;
    }
    else {
      return CACHE_PERMANENT;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
views_object::$options property Except for displays, options for the object will be held here. 1
views_object::construct function Views handlers use a special construct function so that we can more easily construct them with variable arguments. 5
views_object::destroy function 2
views_object::options function Set default options on this object. Called by the constructor in a complex chain to deal with backward compatibility. 1
views_object::option_definition function Information about options for all kinds of purposes will be held here. 9
views_object::set_default_options function Set default options. For backward compatibility, it sends the options array; this is a feature that will likely disappear at some point.
views_object::set_definition function Let the handler know what its full definition is.
views_object::unpack_options function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::_set_option_defaults function 1
views_plugin::additional_theme_functions function Provide a list of additional theme functions for the theme information page
views_plugin::options_submit function Handle any special handling on the validate form. 3
views_plugin::options_validate function Validate the options form. 3
views_plugin::query function Add anything to the query that we might need to. 3
views_plugin::theme_functions function Provide a full list of possible theme templates used by this style.
views_plugin::validate function Validate that the plugin is correct and can be saved. 2
views_plugin_cache::$storage property Contains all data that should be written/read from cache.
views_plugin_cache::$table property What table to store data in.
views_plugin_cache::cache_flush function Clear out cached data for a view.
views_plugin_cache::cache_get function Retrieve data from the cache. 1
views_plugin_cache::cache_set function Save data to the cache. 1
views_plugin_cache::cache_start function Start caching javascript, css and other out of band info. 1
views_plugin_cache::gather_headers function Gather out of band data, compare it to what we started with and store the difference.
views_plugin_cache::get_output_key function
views_plugin_cache::get_results_key function
views_plugin_cache::init function Initialize the plugin. Overrides views_plugin::init
views_plugin_cache::post_render function Post process any rendered data.
views_plugin_cache::restore_headers function Restore out of band data saved to cache. Copied from Panels.
views_plugin_cache_time::cache_expire function Determine the expiration time of the cache type, or NULL if no expire. Overrides views_plugin_cache::cache_expire
views_plugin_cache_time::cache_set_expire function Determine expiration time in the cache table of the cache type or CACHE_PERMANENT if item shouldn't be removed automatically from cache. Overrides views_plugin_cache::cache_set_expire
views_plugin_cache_time::options_form function Provide a form to edit options for this plugin. Overrides views_plugin::options_form
views_plugin_cache_time::option_defaults function Retrieve the default options when this is a new access control plugin Overrides views_plugin_cache::option_defaults
views_plugin_cache_time::summary_title function Return a string to display as the clickable title for the access control. Overrides views_plugin_cache::summary_title