From 66920e4e4b04174d63834d6220c4da76453f27a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Fri, 3 Feb 2017 16:23:04 -0800 Subject: [PATCH] Cache docs in memory across requests --- website/package.json | 9 +++++---- website/server/convert.js | 9 ++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/website/package.json b/website/package.json index e99766193eea39..8f58578f7f32bc 100644 --- a/website/package.json +++ b/website/package.json @@ -16,17 +16,18 @@ "deep-assign": "^2.0.0", "feed": "^0.3.0", "flow-parser": "^0.32.0", - "fs.extra": "1.3.2", + "fs.extra": "*", "glob": "6.0.4", "jsdoc-api": "^1.1.0", "jstransform": "11.0.3", - "mkdirp": "^0.5.1", + "memory-cache": "^0.1.6", + "mkdirp": "*", "optimist": "0.6.0", - "react": "~0.13.0", + "react": "0.13.2", "react-docgen": "^2.9.0", "react-page-middleware": "git://github.com/facebook/react-page-middleware.git", "remove-markdown": "^0.1.0", - "request": "^2.69.0", + "request": "*", "semver-compare": "^1.0.0" }, "devDependencies": { diff --git a/website/server/convert.js b/website/server/convert.js index 168e735d704ae7..299af4d1ac6b87 100644 --- a/website/server/convert.js +++ b/website/server/convert.js @@ -16,6 +16,7 @@ var optimist = require('optimist'); var path = require('path'); var removeMd = require('remove-markdown'); var extractDocs = require('./extractDocs'); +var cache = require('memory-cache'); var argv = optimist.argv; function splitHeader(content) { @@ -91,6 +92,7 @@ function buildFile(layout, metadata, rawContent) { } function execute() { + console.log('execute.start'); var DOCS_MD_DIR = '../docs/'; var BLOG_MD_DIR = '../blog/'; @@ -135,7 +137,12 @@ function execute() { ); } - extractDocs().forEach(function(content) { + var extractedDocs = cache.get('extractedDocs'); + if (!extractedDocs) { + extractedDocs = extractDocs(); + cache.put('extractedDocs', extractedDocs); + } + extractedDocs.forEach(function(content) { handleMarkdown(content, null); });