fix: do not block event loop while doing cleanups#216
Open
simllll wants to merge 4 commits intonode-cache:masterfrom
Open
fix: do not block event loop while doing cleanups#216simllll wants to merge 4 commits intonode-cache:masterfrom
simllll wants to merge 4 commits intonode-cache:masterfrom
Conversation
potenitally fixes node-cache#215, needs more testing though note: I have no idea of coffeescript, is my fix syntacitally correct?
Author
|
Oh right, some test fail now due to the async behaviour. Either we await the setImmediate callback (Can we use async / await in coffeescript?) or we change some other code logic here to let this thing happen asynchronously. |
Author
|
Javascript code that solves the issue on my side: async _checkData(startPeriod = true) {
var key, ref, value;
boundMethodCheck(this, NodeCache);
ref = this.data;
// run the housekeeping method
var i = 0;
for (key in ref) {
value = ref[key];
this._check(key, value);
if (i % 10 === 0) {
await new Promise(resolve => setImmediate(resolve));
}
i++;
}
.... |
this potentially breaks support for older node versions, sorry, I have no idea about coffeescript, just testing out ;)
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
potenitally fixes #215, needs more testing though
note: I have no idea of coffeescript, is my fix syntacitally correct?