class views_plugin_cache_time
- 3.x plugins/views_plugin_cache_time.inc views_plugin_cache_time
- 2.x plugins/views_plugin_cache_time.inc views_plugin_cache_time
Simple caching of query results for Views displays.
Hierarchy
- class \views_object
- class \views_plugin
- class \views_plugin_cache
- class \views_plugin_cache_time
- class \views_plugin_cache
- class \views_plugin
Expanded class hierarchy of views_plugin_cache_time
Related topics
1 string reference to 'views_plugin_cache_time'
- views_views_plugins in includes/
plugins.inc - Implements hook_views_plugins().
File
- plugins/
views_plugin_cache_time.inc, line 13 - Definition of views_plugin_cache_time.
View source
class views_plugin_cache_time extends views_plugin_cache {
function option_definition() {
$options = parent::option_definition();
$options['results_lifespan'] = array('default' => 3600);
$options['results_lifespan_custom'] = array('default' => 0);
$options['output_lifespan'] = array('default' => 3600);
$options['output_lifespan_custom'] = array('default' => 0);
return $options;
}
function options_form(&$form, &$form_state) {
parent::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 + array('custom' => t('Custom'));
$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['results_lifespan_custom'] = array(
'#type' => 'textfield',
'#title' => t('Seconds'),
'#size' => '25',
'#maxlength' => '30',
'#description' => t('Length of time in seconds raw query results should be cached.'),
'#default_value' => $this->options['results_lifespan_custom'],
'#process' => array('form_process_select', 'ctools_dependent_process'),
'#dependency' => array(
'edit-cache-options-results-lifespan' => array('custom'),
),
);
$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'],
);
$form['output_lifespan_custom'] = array(
'#type' => 'textfield',
'#title' => t('Seconds'),
'#size' => '25',
'#maxlength' => '30',
'#description' => t('Length of time in seconds rendered HTML output should be cached.'),
'#default_value' => $this->options['output_lifespan_custom'],
'#process' => array('form_process_select', 'ctools_dependent_process'),
'#dependency' => array(
'edit-cache-options-output-lifespan' => array('custom'),
),
);
}
function options_validate(&$form, &$form_state) {
$custom_fields = array('output_lifespan', 'results_lifespan');
foreach ($custom_fields as $field) {
if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) {
form_error($form[$field . '_custom'], t('Custom time values must be numeric.'));
}
}
}
function summary_title() {
$results_lifespan = $this->get_lifespan('results');
$output_lifespan = $this->get_lifespan('output');
return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1);
}
function get_lifespan($type) {
$lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan'];
return $lifespan;
}
function cache_expire($type) {
$lifespan = $this->get_lifespan($type);
if ($lifespan) {
$cutoff = REQUEST_TIME - $lifespan;
return $cutoff;
}
else {
return FALSE;
}
}
function cache_set_expire($type) {
$lifespan = $this->get_lifespan($type);
if ($lifespan) {
return time() + $lifespan;
}
else {
return CACHE_PERMANENT;
}
}
}
Members
Name | Modifiers | Type | Description |
---|---|---|---|
views_object:: |
function | Views handlers use a special construct function so that we can more easily construct them with variable arguments. | |
views_object:: |
function | ||
views_object:: |
function | ||
views_object:: |
function | ||
views_object:: |
function | Always exports the option, regardless of the default value. | |
views_object:: |
function | Set default options on this object. Called by the constructor in a complex chain to deal with backward compatibility. | |
views_object:: |
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:: |
function | Let the handler know what its full definition is. | |
views_object:: |
function | Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away. | |
views_object:: |
function | Unpack a single option definition. | |
views_object:: |
function | Unpacks each handler to store translatable texts. | |
views_object:: |
function | ||
views_plugin:: |
function | Provide a list of additional theme functions for the theme information page | |
views_plugin:: |
function | Handle any special handling on the validate form. | |
views_plugin:: |
function | Return the human readable name of the display. | |
views_plugin:: |
function | Add anything to the query that we might need to. | |
views_plugin:: |
function | Provide a full list of possible theme templates used by this style. | |
views_plugin:: |
function | Validate that the plugin is correct and can be saved. | |
views_plugin_cache:: |
function | Clear out cached data for a view. | |
views_plugin_cache:: |
function | Retrieve data from the cache. | |
views_plugin_cache:: |
function | Save data to the cache. | |
views_plugin_cache:: |
function | Start caching javascript, css and other out of band info. | |
views_plugin_cache:: |
function | Gather out of band data, compare it to what we started with and store the difference. | |
views_plugin_cache:: |
function | ||
views_plugin_cache:: |
function | ||
views_plugin_cache:: |
function | Initialize the plugin. | |
views_plugin_cache:: |
function | Post process any rendered data. | |
views_plugin_cache:: |
function | Restore out of band data saved to cache. Copied from Panels. | |
views_plugin_cache_time:: |
function |
Determine the expiration time of the cache type, or NULL if no expire. Overrides views_plugin_cache:: |
|
views_plugin_cache_time:: |
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:: |
|
views_plugin_cache_time:: |
function | ||
views_plugin_cache_time:: |
function |
Provide a form to edit options for this plugin. Overrides views_plugin:: |
|
views_plugin_cache_time:: |
function |
Validate the options form. Overrides views_plugin:: |
|
views_plugin_cache_time:: |
function |
Information about options for all kinds of purposes will be held here.
@code
'option_name' => array( Overrides views_object:: |
|
views_plugin_cache_time:: |
function |
Return a string to display as the clickable title for the
access control. Overrides views_plugin_cache:: |