-
Notifications
You must be signed in to change notification settings - Fork 138
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
Can 'node-cache' block node event loop? #215
Comments
Looking into similiar issues on our end right now. If you find something, let me know please! |
potenitally fixes node-cache#215, needs more testing though note: I have no idea of coffeescript, is my fix syntacitally correct?
@simllll , Did you set TTL as 1min? |
TTL was different, but checkperiod was set to 60. I tried now setting it to 0 (to disable the check), but turned out it didn't make any difference. Therefore I assume this is not the real issue here. Can you try setting checkperiod to 0 on your side to see if it changes something? Simon |
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. |
One possible optimization would be to dereference all the expired keys in one statement vs while looping over them. By keeping a reference to all the to-be-evicted-soon objects in one place until we're about to be done with the check and dereferencing them en masse would mean that we trigger one GC vs a dice roll on each dereference on each iteration of the loop. |
The API of check could change. Right now check actually does the delete. Instead it could return a boolean of if the key should be evicted. Then we could collect an array of keys to evict in checkData. After looping we could do one call to del with all the keys to be evicted. We might also want to change the the del code to keep one final reference from key -> oldVal. Which will dereference when the function returns triggering 1 GC (if the engine wants to run it) |
In our project, we use node-cache as a cache layer.
We found an issue which looks like a API performance issue.
Our API responds status code '499' (client connection close, cause by our API response time is over client's limit), every 5minutes.
When we were looking for the reason, we found that we set node-cache TTL as 5minutes.
If node-cache block node's event loop when flush data, node server can't respond to API request during that time.
We are wondering if 'node-cache' block node event loop or not.
Thank you
The text was updated successfully, but these errors were encountered: