Re: [nodejs]will kilos setTimeout spend too much resourece?
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 are not a good, and not that much accurate. > > > On Monday, 23 April 2012 13:49:08 UTC+8, Jason.桂林 wrote: >> >> 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/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Best regards, Jason Green 桂林 -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs]will kilos setTimeout spend too much resourece?
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, 23 April 2012 13:49:08 UTC+8, Jason.桂林 wrote: > > 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/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs]will kilos setTimeout spend too much resourece?
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 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 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/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Best regards, Jason Green 桂林 -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs]will kilos setTimeout spend too much resourece?
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 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/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en