I am using NodeJS by express framework, now I want to use the memory cache to save objects(almost 3000).
I have thought create a file like
cache.js:
var cache={};
module.exports=cache;
Then in any module I need the cache I can require it:
require('cache')
cache.xx=xxx
However it seems that I can not make sure that the cache
object will be create and will be only one copy during the app running. Since the require
may use the module cache or not.(from this link:https://stackoverflow.com/a/9210901/306719)
Any suggestion?