Node timing data processing

scenario: when a piece of data is created successfully, it is regularly determined to modify and update the data

testModel.create({name:"a",num:2},function(err,doc){
if(doc){
setTimeout(do,gettime())
function do(){
 update
}
}
})

express framework uses mongoose to connect mongodb,. Is it feasible to use setTimeout,setInterval in the actual production environment? of course, node also has many timing modules. How do you deal with scheduled tasks like above?

Apr.05,2021

setTimeout and setInterval are possible, but not good enough.

you can write an additional UpdateTsk component that maintains an array of functions that need to be executed regularly
, such as UpdateTsk.reg (CallBack_Func) , etc., and then let the component schedule itself to call all the callback_Func in the list

.

if it is setTimeout and setInterval, there will be tens of thousands of timers in the last possible program, which has a certain impact on efficiency

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e424c0-4347e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e424c0-4347e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?