Changeset 28491


Ignore:
Timestamp:
05/17/14 08:09:33 (5 years ago)
Author:
rvelices
Message:

use persistent cache for calendar list in root flat mode (same perf improvement as category flat view)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_calendar.inc.php

    r26461 r28491  
    3737function initialize_calendar() 
    3838{ 
    39   global $page, $conf, $user, $template, $filter; 
     39  global $page, $conf, $user, $template, $persistent_cache, $filter; 
    4040 
    4141//------------------ initialize the condition on items to take into account --- 
     
    270270  if ($must_show_list) 
    271271  { 
    272     $query = 'SELECT DISTINCT id '; 
    273     $query .= ','.$calendar->date_field; 
    274     $query .= $calendar->inner_sql.' 
    275   '.$calendar->get_date_where(); 
    276272    if ( isset($page['super_order_by']) ) 
    277273    { 
    278       $query .= ' 
    279   '.$conf['order_by']; 
     274      $order_by = $conf['order_by']; 
    280275    } 
    281276    else 
     
    294289        'ORDER BY '.$calendar->date_field.$order, $conf['order_by'] 
    295290        ); 
    296       $query .= ' 
     291    } 
     292     
     293    if ('categories'==$page['section'] && !isset($page['category']) 
     294      && ( count($page['chronology_date'])==0 
     295            OR ($page['chronology_date'][0]=='any' && count($page['chronology_date'])==1) ) 
     296      ) 
     297    { 
     298      $cache_key = $persistent_cache->make_key($user['id'].$user['cache_update_time'] 
     299        .$calendar->date_field.$order_by); 
     300    } 
     301 
     302    if ( !isset($cache_key) || !$persistent_cache->get($cache_key, $page['items'])) 
     303    { 
     304      $query = 'SELECT DISTINCT id ' 
     305        .$calendar->inner_sql.' 
     306  '.$calendar->get_date_where().' 
    297307  '.$order_by; 
    298     } 
    299     $page['items'] = array_from_query($query, 'id'); 
     308      $page['items'] = array_from_query($query, 'id'); 
     309      if ( isset($cache_key) ) 
     310        $persistent_cache->set($cache_key, $page['items']); 
     311    } 
    300312  } 
    301313  pwg_debug('end initialize_calendar'); 
Note: See TracChangeset for help on using the changeset viewer.