Add a 'last_action' datetime column to your user database, and do:

UPDATE users SET last_action = now() WHERE username = 'someuser'

on every nth request a (logged in) user does.

As for getting the current logged in users

SELECT username FROM users WHERE last_action > now() - interval '2
minute'

assuming you're using postgresql

You could add an index on last_action but that would slow down the
UPDATE query which is done on every request for every user, so it's a
better idea to not to add the index, and instead cache that second
query for a minute or so in something like memcached.


On Mar 9, 12:21 am, "przemek.ch" <[email protected]> wrote:
> Ok but You'll need a lot of memory to use memcached.
> I was wondering if it would be possible check if a session has expired
> using database/filesystem session type.
> Any ideas?
>
> On 8 Mar, 18:16, Jonathan Vanasco <[email protected]> wrote:
>
>
>
> > you might be better off using memcached to handle this, as it would
> > scale across processes and servers - and it would be very lightweight
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to