use persistent cache for calendar list in root flat mode (same perf improvement as category flat view)
git-svn-id: http://piwigo.org/svn/trunk@28491 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
99ea8d67d4
commit
9f8d9443c9
1 changed files with 21 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ define('CAL_VIEW_CALENDAR', 'calendar');
|
|||
*/
|
||||
function initialize_calendar()
|
||||
{
|
||||
global $page, $conf, $user, $template, $filter;
|
||||
global $page, $conf, $user, $template, $persistent_cache, $filter;
|
||||
|
||||
//------------------ initialize the condition on items to take into account ---
|
||||
$inner_sql = ' FROM ' . IMAGES_TABLE;
|
||||
|
|
@ -269,14 +269,9 @@ WHERE id IN (' . implode(',',$page['items']) .')';
|
|||
|
||||
if ($must_show_list)
|
||||
{
|
||||
$query = 'SELECT DISTINCT id ';
|
||||
$query .= ','.$calendar->date_field;
|
||||
$query .= $calendar->inner_sql.'
|
||||
'.$calendar->get_date_where();
|
||||
if ( isset($page['super_order_by']) )
|
||||
{
|
||||
$query .= '
|
||||
'.$conf['order_by'];
|
||||
$order_by = $conf['order_by'];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -293,10 +288,27 @@ WHERE id IN (' . implode(',',$page['items']) .')';
|
|||
'ORDER BY ',
|
||||
'ORDER BY '.$calendar->date_field.$order, $conf['order_by']
|
||||
);
|
||||
$query .= '
|
||||
'.$order_by;
|
||||
}
|
||||
$page['items'] = array_from_query($query, 'id');
|
||||
|
||||
if ('categories'==$page['section'] && !isset($page['category'])
|
||||
&& ( count($page['chronology_date'])==0
|
||||
OR ($page['chronology_date'][0]=='any' && count($page['chronology_date'])==1) )
|
||||
)
|
||||
{
|
||||
$cache_key = $persistent_cache->make_key($user['id'].$user['cache_update_time']
|
||||
.$calendar->date_field.$order_by);
|
||||
}
|
||||
|
||||
if ( !isset($cache_key) || !$persistent_cache->get($cache_key, $page['items']))
|
||||
{
|
||||
$query = 'SELECT DISTINCT id '
|
||||
.$calendar->inner_sql.'
|
||||
'.$calendar->get_date_where().'
|
||||
'.$order_by;
|
||||
$page['items'] = array_from_query($query, 'id');
|
||||
if ( isset($cache_key) )
|
||||
$persistent_cache->set($cache_key, $page['items']);
|
||||
}
|
||||
}
|
||||
pwg_debug('end initialize_calendar');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue