diff --git a/db/boards.js b/db/boards.js index bfee7707..f7ce88d7 100644 --- a/db/boards.js +++ b/db/boards.js @@ -15,12 +15,12 @@ module.exports = { } else { board = await db.findOne({ '_id': name }); if (board) { - cache.set(`board_${name}`, board); + cache.set(`board_${name}`, board, 3600); if (board.banners.length > 0) { cache.sadd(`banners_${name}`, board.banners); } } else { - cache.set(`board_${name}`, 'no_exist', 'ex', 3600); //1 hour expiry just so it doesnt grow indefinitely + cache.set(`board_${name}`, 'no_exist', 600); } } return board; diff --git a/redis.js b/redis.js index cd05821b..09958224 100644 --- a/redis.js +++ b/redis.js @@ -14,8 +14,12 @@ module.exports = { }, //set a value on key - set: (key, value) => { - return client.set(key, JSON.stringify(value)); + set: (key, value, ttl) => { + if (ttl) { + client.set(key, JSON.stringify(value), 'EX', ttl); + } else { + client.set(key, JSON.stringify(value)); + } }, //add items to a set