by benologist · 14y ago · 0 comments
var queue = [];
// request handling
module.exports = function(request, response) {
queue.push("bla");
response.end("bye");
};
// out-of-request work
setInterval(function() {
// do something with your queue either locally
// or moving it to an external job queue that can
// leverage the same script on a different thread
}, 1000);In my case I periodically query mongodb for new or updated data since the last time to be stored locally, push batches of data into redis, track and save load information etc all without any negative repercussions.