function removeCached(mod) {
delete require.cache[require.resolve(mod)];
}
// then
require('foo');
// ... later
removeCached('foo');
2013/8/17 Tony Huang <[email protected]>
> 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 [email protected]
> [email protected]
> [email protected]
>
> --
> --
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.