diff options
| author | Savetheinternet <savetheinternet@tinyboard.org> | 2011-10-08 17:46:48 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@tinyboard.org> | 2011-10-08 17:46:48 +1100 |
| commit | 3520a10f0df5b3dd094d5f68d3ff5305b32d92aa (patch) | |
| tree | e72e83469a3b1ebb4e6bbf66b9f837c369dd2126 /inc/functions.php | |
| parent | 9ba135ffcd3046c9330ea23752e5749e543f1d74 (diff) | |
additional cache
Diffstat (limited to 'inc/functions.php')
| -rw-r--r-- | inc/functions.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php index 56bb011e..d5295b16 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -207,17 +207,29 @@ } function openBoard($uri) { + global $config; + if($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { + setupBoard($board); + return true; + } + $query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1"); $query->bindValue(':uri', $uri); $query->execute() or error(db_error($query)); if($board = $query->fetch()) { + if($config['cache']['enabled']) + cache::set('board_' . $uri, $board); setupBoard($board); return true; } else return false; } function boardTitle($uri) { + if($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { + return $board['title']; + } + $query = prepare("SELECT `title` FROM `boards` WHERE `uri` = :uri LIMIT 1"); $query->bindValue(':uri', $uri); $query->execute() or error(db_error($query)); @@ -337,8 +349,17 @@ } function listBoards() { + global $config; + + if($config['cache']['enabled'] && ($boards = cache::get('all_boards'))) + return $boards; + $query = query("SELECT * FROM `boards` ORDER BY `uri`") or error(db_error()); $boards = $query->fetchAll(); + + if($config['cache']['enabled']) + cache::set('all_boards', $boards); + return $boards; } |
