From: Eric Hodel Date: 2005-10-28T05:05:43+09:00 Subject: Re: mod_ruby object persistence On Oct 27, 2005, at 6:58 AM, tsuraan wrote: > How long do objects stick around in mod_ruby? I have a really simple > pair of files: > > countersingle.rb: > ----- > require 'singleton' > > class Counter > include Singleton > def initialize() > @counter = 0 > end > > def get() > @counter += 1 > end > end > ----- > and counter.rhtml: > ----- > > > <% require 'countersingle' %> > <%= Counter.instance.get %> > > > ----- > > When I am refreshing the page, the count goes up. If I wait a minute > or so, the count gets reset to zero. So, I'm wondering if there's > some way to force persistence with mod_ruby, or is there a garbage > collection that happens after a minute of inactivity that will always > clear up everything that's not relevent anymore? A class will stay around as long as its apache process is alive. Of course, if you go to a different apache process you'll have a different class. You'll need a global-to-the-machine place to store your counter if you want it to work right. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04