From f1f7e5d4ad0d6bb5cbf170063ec7aec2abb3761d Mon Sep 17 00:00:00 2001 From: rvelices Date: Sun, 11 May 2014 08:26:41 +0000 Subject: added a persistent cache mechanism; used so far to cache image ids in flat view mode git-svn-id: http://piwigo.org/svn/trunk@28432 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/section_init.inc.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include/section_init.inc.php') diff --git a/include/section_init.inc.php b/include/section_init.inc.php index cbc699d45..8ab635875 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -291,6 +291,7 @@ SELECT id } else { + $cache_key = $persistent_cache->make_key('all_iids'.$user['id'].$user['cache_update_time'].$conf['order_by']); unset($page['is_homepage']); $where_sql = '1=1'; } @@ -301,8 +302,10 @@ SELECT id $where_sql = 'category_id = '.$page['category']['id']; } - // main query - $query = ' + if ( !isset($cache_key) || !$persistent_cache->get($cache_key, $page['items'])) + { + // main query + $query = ' SELECT DISTINCT(image_id) FROM '.IMAGE_CATEGORY_TABLE.' INNER JOIN '.IMAGES_TABLE.' ON id = image_id @@ -312,7 +315,11 @@ SELECT DISTINCT(image_id) '.$conf['order_by'].' ;'; - $page['items'] = query2array($query,null, 'image_id'); + $page['items'] = query2array($query,null, 'image_id'); + + if ( isset($cache_key) ) + $persistent_cache->set($cache_key, $page['items']); + } } } // special sections -- cgit v1.2.3