aboutsummaryrefslogtreecommitdiffstats
path: root/include/section_init.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2014-05-11 08:26:41 +0000
committerrvelices <rv-github@modusoptimus.com>2014-05-11 08:26:41 +0000
commitf1f7e5d4ad0d6bb5cbf170063ec7aec2abb3761d (patch)
tree0e83ddba02373679c530f20bf3f7bc2f86fe2bf5 /include/section_init.inc.php
parentb4decbe52f0bb8213c0320e24ff292cd02e5657f (diff)
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
Diffstat (limited to 'include/section_init.inc.php')
-rw-r--r--include/section_init.inc.php13
1 files changed, 10 insertions, 3 deletions
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