Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory limiter: dump and restore functionality #40

Open
sido420 opened this issue Sep 28, 2019 · 6 comments
Open

Memory limiter: dump and restore functionality #40

sido420 opened this issue Sep 28, 2019 · 6 comments
Labels

Comments

@sido420
Copy link

sido420 commented Sep 28, 2019

I was thinking if we could add a dump/restore functionality to this module.

Due to the nature of nodejs process, if it goes down we loose everything stored in the in-memory db.

What are your thoughts?

@animir
Copy link
Owner

animir commented Sep 28, 2019

@sido420 This is interesting idea. It would be definitely useful to have such feature in some cases.

@animir animir added the enhancement New feature or request label Sep 28, 2019
@sido420
Copy link
Author

sido420 commented Sep 28, 2019

It came from the popular LRU cache nodejs module, see https://github.com/isaacs/node-lru-cache.

I think it'd be a huge benefit for single node setups where external storage is unavailable. Or, even multi process setups with sticky sessions etc. or even without sticky sessions it might be of help. Quick app prototypes should also benefit from it :)

@animir
Copy link
Owner

animir commented Sep 29, 2019

@sido420 Yeah, I think so. Community would appreciate it. Let us know if you started to implement it, so nobody else does the same in parallel. Thanks.

@sido420
Copy link
Author

sido420 commented Sep 30, 2019

No, I haven't started any work on it.

I will comment here if I plan on doing so (not anytime soon).

@animir animir added feature and removed enhancement New feature or request labels Oct 5, 2019
@sido420
Copy link
Author

sido420 commented Oct 8, 2019

I stringified _storage in memory storage and got the following:

{"_storage":{"Msg-ByID:1":{"_value":1,"_expiresAt":"2019-10-08T00:59:58.025Z","_timeoutId":{"_called":false,"_idleTimeout":600000,"_idlePrev":null,"_idleNext":null,"_idleStart":229
:/conta│15556,"_repeat":null,"_destroyed":false,"_handle":{}}}}}

Can you tell me what needs to persist so it could be restored at startup?

@animir
Copy link
Owner

animir commented Oct 13, 2019

@sido420 _timeoutId contains data we can't use really. Every key should re-create a timer with setTimeout function depending on _expiresAt and set _timeoutId. So you could remove _timeoutId from dump.

@animir animir changed the title dump and restore functionality for in memory storage Memory limiter: dump and restore functionality Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants