On Aug 3, 2009, at 4:53 PM, Hassan Schroeder wrote: > > On Mon, Aug 3, 2009 at 12:45 PM, Phoenix Rising<polarisris...@gmail.com > > wrote: >> >> I'm developing an application where I need to have all sessions that >> have been inactive for X minutes (in this case, I'm thinking 10 >> minutes, but I'm flexible to a point) automatically purged from the >> database (using ActiveRecord session store). > >> However, I'm concerned that running a rake task every 10 minutes >> could have some performance issues. > > This is something I've been looking into (but not implemented) and > the problem with this approach seems to be the startup overhead of > loading your Rails environment over and over. > > So you might want to look at the various daemon options, i.e. just > run something continuously to periodically expunge old sessions. > > FWIW, > --
Well, what you are both looking at doing is: Session.delete_all, :conditions => ['updated_at < ?', 10.minutes.ago] That translates into a pretty quick database query, depending on the number of sessions you anticipate having. WDYT? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---