[nodejs]will kilos setTimeout spend too much resourece?

2012-04-22 Thread jason . 桂林
I need to write a service use something like in memory cache, and I want to do `expire` things in setTimeout, will it very slow, If I expire too much things, about kilos to millions. -- Best regards, Jason Green 桂林 -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/j

Re: [nodejs]will kilos setTimeout spend too much resourece?

2012-04-22 Thread Joran Greef
If you pass a function reference to an existing function to setTimeout, and then call this function repeatedly, rather than creating a closure each setTimeout call, that will lower your memory and cpu overhead substantially. On Monday, April 23, 2012 7:49:08 AM UTC+2, Jason.桂林 wrote: > > I need

Re: [nodejs]will kilos setTimeout spend too much resourece?

2012-04-23 Thread jason . 桂林
Oh cool! and I found setTimeout(console.log, 1000, 'hello world') is much better than setTimeout(function(){ console.log('hello world'); }, 1000) 在 2012年4月23日 下午2:32,Joran Greef 写道: > If you pass a function reference to an existing function to setTimeout, > and then call this function repea

Re: [nodejs]will kilos setTimeout spend too much resourece?

2012-04-24 Thread alFReD NSH
I think for something like that you should decide how accurate you want to be and use a function on an interval to remove all expired things. Like run the function on every minute or every second, depending on your need. A A lot of timers are not a good, and not that much accurate. On Monday,

Re: [nodejs]will kilos setTimeout spend too much resourece?

2012-04-25 Thread jason . 桂林
Reasonable ! 在 2012年4月25日 上午10:30,alFReD NSH 写道: > I think for something like that you should decide how accurate you want to > be and use a function on an interval to remove all expired things. Like run > the function on every minute or every second, depending on your need. A A > lot of timers