mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 17:54:29 +01:00
cache entire thread HTML
This commit is contained in:
parent
6d45a812f0
commit
6db20471cd
@ -53,6 +53,9 @@
|
|||||||
$config['memcached']['servers'] = Array(
|
$config['memcached']['servers'] = Array(
|
||||||
Array('localhost', 11211)
|
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)
|
// The name of the session cookie (PHP's $_SESSION)
|
||||||
$config['cookies']['session']= 'imgboard';
|
$config['cookies']['session']= 'imgboard';
|
||||||
|
@ -201,8 +201,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openBoard($uri) {
|
function openBoard($uri) {
|
||||||
|
|
||||||
|
|
||||||
$query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1");
|
$query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1");
|
||||||
$query->bindValue(':uri', $uri);
|
$query->bindValue(':uri', $uri);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
@ -1223,9 +1221,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildThread($id, $return=false, $mod=false) {
|
function buildThread($id, $return=false, $mod=false) {
|
||||||
global $board, $config;
|
global $board, $config, $memcached;
|
||||||
$id = round($id);
|
$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 = 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->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
@ -1252,6 +1257,10 @@
|
|||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
|
'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)
|
if($return)
|
||||||
return $body;
|
return $body;
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user