/[drupal]/contributions/modules/views/plugins/views_plugin_cache_time.inc
ViewVC logotype

Contents of /contributions/modules/views/plugins/views_plugin_cache_time.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Tue Jun 30 21:57:22 2009 UTC (4 months, 4 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-7--3
Changes since 1.2: +2 -1 lines
File MIME type: text/x-php
#503774 by dereine: Cache time failed to return the proper cutoff time.
1 <?php
2 // $Id: views_plugin_cache_time.inc,v 1.2 2009/06/03 23:39:52 merlinofchaos Exp $
3
4 /**
5 * Simple caching of query results for Views displays.
6 */
7 class views_plugin_cache_time extends views_plugin_cache {
8 function option_defaults(&$options) {
9 $options['results_lifespan'] = 3600;
10 $options['output_lifespan'] = 3600;
11 }
12
13 function options_form(&$form, &$form_state) {
14 $options = array(60, 300, 1800, 3600, 21600, 518400);
15 $options = drupal_map_assoc($options, 'format_interval');
16 $options = array(-1 => t('Never cache')) + $options;
17
18 $form['results_lifespan'] = array(
19 '#type' => 'select',
20 '#title' => t('Query results'),
21 '#description' => t('The length of time raw query results should be cached.'),
22 '#options' => $options,
23 '#default_value' => $this->options['results_lifespan'],
24 );
25 $form['output_lifespan'] = array(
26 '#type' => 'select',
27 '#title' => t('Rendered output'),
28 '#description' => t('The length of time rendered HTML output should be cached.'),
29 '#options' => $options,
30 '#default_value' => $this->options['output_lifespan'],
31 );
32 }
33
34 function summary_title() {
35 return format_interval($this->options['results_lifespan'], 1) . '/' . format_interval($this->options['output_lifespan'], 1);
36 }
37
38 function cache_expire($type) {
39 if ($lifespan = $this->options[$type . '_lifespan']) {
40 $cutoff = time() - $lifespan;
41 return $cutoff;
42 }
43 else {
44 return FALSE;
45 }
46 }
47
48 }

  ViewVC Help
Powered by ViewVC 1.1.2