Let''s say I have an application and I want to create an admin program that will show me who is currently online using the application. I don''t know the best way to do this. Assuming I am storing my sessions in the default PStore, I don''t suppose there is any method that lists all the active sessions, is there? The only way I can think of to do this is to setup a database table that stores timestamps and user IDs for every page request. I can expire the sessions after 30 minutes of inactivity and in my admin program (that reports the online users), I can remove the records that are more than 30 minutes old when creating the report. Is there a better way? Shelby
Yes, use ActiveRecordStore. PStore has horrible performance anyway. SIMEN BREKKEN / born to synthesize. Shelby Westman wrote:> Let''s say I have an application and I want to create an admin program > that will show me who is currently online using the application. I > don''t know the best way to do this. Assuming I am storing my sessions > in the default PStore, I don''t suppose there is any method that lists > all the active sessions, is there? > > The only way I can think of to do this is to setup a database table > that stores timestamps and user IDs for every page request. I can > expire the sessions after 30 minutes of inactivity and in my admin > program (that reports the online users), I can remove the records that > are more than 30 minutes old when creating the report. > > Is there a better way? > > Shelby
This is a pretty standard way to handle sessions. You can use an updated_at field, and perhaps keep track of other useful data. A quick way to make this perform well is to use a MySQL memory table (though most would recommend memcached over this solution). You might want to just run a cron job that wipes out old records. Joshua Sierles On 8/8/05, Simen Brekken <simen-qaH4BmqzZooOvCyXmLEu7A@public.gmane.org> wrote:> > Yes, use ActiveRecordStore. PStore has horrible performance anyway. > > > SIMEN BREKKEN / born to synthesize. > > Shelby Westman wrote: > > Let''s say I have an application and I want to create an admin program > > that will show me who is currently online using the application. I > > don''t know the best way to do this. Assuming I am storing my sessions > > in the default PStore, I don''t suppose there is any method that lists > > all the active sessions, is there? > > > > The only way I can think of to do this is to setup a database table > > that stores timestamps and user IDs for every page request. I can > > expire the sessions after 30 minutes of inactivity and in my admin > > program (that reports the online users), I can remove the records that > > are more than 30 minutes old when creating the report. > > > > Is there a better way? > > > > Shelby > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> The only way I can think of to do this is to setup a database table > that stores timestamps and user IDs for every page request. I can > expire the sessions after 30 minutes of inactivity and in my admin > program (that reports the online users), I can remove the records that > are more than 30 minutes old when creating the report. > > Is there a better way?Perhaps a lastlog approach? i.e. each time a user makes a request you could update their ''last_request_at'' attribute with a filter. However you''ll get some serious contention for those tables. -- Cheers Koz