From 248b41081ce6594e0051225ef7e9609805bc600f Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Sun, 12 Jul 2020 14:50:14 +1000 Subject: [PATCH] same shit for overboard --- models/pages/overboard.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/models/pages/overboard.js b/models/pages/overboard.js index 3ae08e49..223b1536 100644 --- a/models/pages/overboard.js +++ b/models/pages/overboard.js @@ -6,13 +6,16 @@ const { Posts, Boards } = require(__dirname+'/../../db/') module.exports = async (req, res, next) => { - let threads = []; - try { - const listedBoards = await Boards.getLocalListed(); - threads = await Posts.getRecent(listedBoards, 1, overboardLimit, false, false); - } catch (err) { - return next(err); - } + let threads = (await cache.get('overboard')) || []; + if (!threads || threads.length === 0) { + try { + const listedBoards = await Boards.getLocalListed(); + threads = await Posts.getRecent(listedBoards, 1, overboardLimit, false, false); + cache.set('overboard', threads, 60); + } catch (err) { + return next(err); + } + } res .set('Cache-Control', 'public, max-age=60')