K
K
krytPhylosoph2020-06-15 10:58:44
Node.js
krytPhylosoph, 2020-06-15 10:58:44

Regular actions in nodejs?

I have a nodejs application with a database. Periodically (preferably once every few minutes) it is necessary to query the database to check for changes in the information in it. Now all this is done through setInterval(...). This method seems to me not very practical, so I'm wondering: are there better methods to perform periodic actions? Maybe you should use CRON?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-06-15
@krytPhylosoph

There is more than one package for such cases. google nodejs scheduler
Which one to choose - according to your preferences and tasks. cron is also possible. Perhaps setInterval is great for you, what exactly is its "impracticality"?
I used https://www.npmjs.com/package/agenda - its pros and cons.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question