From 54e844cf08cdb55b4236eb3d1d2c1d13bbd4b921 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 7 Oct 2010 09:58:08 -0700 Subject: [PATCH] add require.cache --- doc/api.markdown | 4 ++++ src/node.js | 1 + 2 files changed, 5 insertions(+) diff --git a/doc/api.markdown b/doc/api.markdown index 7469cbab6c..7b95ab286e 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -3243,6 +3243,10 @@ a directory. paths onto it, or at startup with the `NODE_PATH` environmental variable (which should be a list of paths, colon separated). +The second time `require('foo')` is called, it is not loaded again from +disk. It looks in the `require.cache` object to see if it has been loaded +before. + ## Addons diff --git a/src/node.js b/src/node.js index 6d53ea3425..187351839a 100644 --- a/src/node.js +++ b/src/node.js @@ -268,6 +268,7 @@ var module = (function () { require.extensions = extensions; // TODO: Insert depreciation warning require.registerExtension = registerExtension; + require.cache = moduleCache; var dirname = path.dirname(filename);