Skip to content

Commit

Permalink
Cache docs in memory across requests
Browse files Browse the repository at this point in the history
  • Loading branch information
hramos committed Feb 4, 2017
1 parent 9587470 commit 66920e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
9 changes: 8 additions & 1 deletion website/server/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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/';

Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit 66920e4

Please sign in to comment.