@Tony The latter. If you need more control and stability then you could roll your own module loading/injecting system with fs, vm or eval.
2013/8/17 Tony Huang <cnwz...@gmail.com> > @George > This is really cool! Is this a public API? Or it's just hacking into the > internal implementation of node.js? > > > On Sat, Aug 17, 2013 at 5:42 PM, George Stagas <gsta...@gmail.com> wrote: > >> function removeCached(mod) { >> delete require.cache[require.resolve(mod)]; >> } >> >> // then >> >> require('foo'); >> >> // ... later >> >> removeCached('foo'); >> >> >> >> 2013/8/17 Tony Huang <cnwz...@gmail.com> >> >>> Hi all, >>> >>> I'm creating a framework for my game server, and developing the module >>> hot update feature. >>> >>> My design is very similar to the Erlang hot update feature. Modules will >>> be hot updated should meet the interface: >>> module.exports = { >>> 'status': "data", >>> 'version': "1.0", >>> 'init': function() { >>> return initialStatus; >>> }, >>> 'code_changed': function(oldVersion, newVersion, oldStatus) { >>> return newStatus; >>> } >>> }; >>> >>> So, when the module source file changes, the framework will get the >>> status of original version of module, and remove it from the module cache, >>> and import the new module, and invoke the code_changed method of the new >>> version of module to generate the new status and assign it to the new >>> module to finish the update process. >>> >>> As a result, I need an API to remove the module from the module cache, >>> will it be possible or will this API be added in the future version of >>> node? >>> >>> Best regards. >>> >>> -- >>> ------------------------------------------------------ >>> Tony Huang cnwz...@gmail.com >>> wz...@hotmail.com >>> wz...@vip.sina.com >>> >>> -- >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to nodejs@googlegroups.com >>> To unsubscribe from this group, send email to >>> nodejs+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to nodejs+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to nodejs@googlegroups.com >> To unsubscribe from this group, send email to >> nodejs+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> --- >> You received this message because you are subscribed to the Google Groups >> "nodejs" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nodejs+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > ------------------------------------------------------ > Tony Huang cnwz...@gmail.com > wz...@hotmail.com > wz...@vip.sina.com > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to nodejs+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.