aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2014-05-17 06:09:33 +0000
committerrvelices <rv-github@modusoptimus.com>2014-05-17 06:09:33 +0000
commit9f8d9443c961436b6e7ca908d97b9db1d07bb226 (patch)
treed470e2e20122ff3d081a9d339bba21806c812c7f /include
parent99ea8d67d458ee5864918f59ff2c3460e048065c (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/functions_calendar.inc.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index 2f71e5d94..30cdb0db0 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -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 .= '
+ }
+
+ 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']);
}
- $page['items'] = array_from_query($query, 'id');
}
pwg_debug('end initialize_calendar');
}