summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-05-19 21:42:53 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-05-19 21:42:53 +1000
commita9b5230003706adf44a4c0648e0b626b0dfdd232 (patch)
treef90a2588a5b9b62614f87db71f42419ff429e489 /inc
parentae06722d3f8153ea6d3fb5d3f1b2a1e329686ae1 (diff)
cache entire thread HTML
Diffstat (limited to 'inc')
-rw-r--r--inc/config.php3
-rw-r--r--inc/functions.php17
2 files changed, 16 insertions, 4 deletions
diff --git a/inc/config.php b/inc/config.php
index 5df82710..cceaabe2 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -53,6 +53,9 @@
$config['memcached']['servers'] = Array(
Array('localhost', 11211)
);
+ // Experimental: cache entire thread HTML (for mods, since we already cache it with static HTML anyway)
+ // Increases load times for mods but might take up a bit of memory
+ $config['memcached']['cache_threads'] = false;
// The name of the session cookie (PHP's $_SESSION)
$config['cookies']['session']= 'imgboard';
diff --git a/inc/functions.php b/inc/functions.php
index d9bd681e..20f38c6e 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -201,8 +201,6 @@
}
function openBoard($uri) {
-
-
$query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1");
$query->bindValue(':uri', $uri);
$query->execute() or error(db_error($query));
@@ -615,7 +613,7 @@
while($po = $posts->fetch()) {
if($po['file'])
$num_images++;
-
+
$thread->add(new Post($po['id'], $th['id'], $po['subject'], $po['email'], $po['name'], $po['trip'], $po['capcode'], $po['body'], $po['time'], $po['thumb'], $po['thumbwidth'], $po['thumbheight'], $po['file'], $po['filewidth'], $po['fileheight'], $po['filesize'], $po['filename'], $po['ip'], $po['embed'], $mod ? '?/' : $config['root'], $mod));
}
@@ -1223,9 +1221,16 @@
}
function buildThread($id, $return=false, $mod=false) {
- global $board, $config;
+ global $board, $config, $memcached;
$id = round($id);
+ if($config['memcached']['cache_threads'] && $config['memcached']['enabled'] && $return && $mod) {
+ // Experimental: cache entire threads (for mods, since we already cache it with static HTML anyway)
+ if($body = $memcached->get('thread_' . $board['uri'] . '_' . $id)) {
+ return $body;
+ }
+ }
+
$query = prepare(sprintf("SELECT * FROM `posts_%s` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`time`", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
@@ -1251,6 +1256,10 @@
'hidden_inputs' => $content['hidden_inputs'] = createHiddenInputs(),
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
));
+
+ if($config['memcached']['cache_threads'] && $config['memcached']['enabled']) {
+ $memcached->set('thread_' . $board['uri'] . '_' . $id, $body, time() + 60);
+ }
if($return)
return $body;