Reputation: 1787
I understand that Node is essentially single threaded, but is there a way to achieve the kind of automated async behaviour that you could achieve in, for example, a Java Spring application by just sparking off a new Thread (or similar)?
My actual requirement is to periodically - and without prompting from a user event - iterate through various caches and selectively refresh only the data that has expired. The refresh itself can take some time, so ideally I don't want to wait until the user clicks before it decides to clean up the cache.
Alternatively, if there is a way to achieve this without having to create a completely independent thread, please enlighten me.
Upvotes: 0
Views: 52
Reputation: 1507
You can use cluster npm, so it will create multiple thread.
Using cluster it will create co worker
Ref code click here
Upvotes: 2
Reputation: 387
Use can use webworkers threads API of JS to implement this functionalty. Refer to the npm package for more information webworker-threads
Upvotes: 0