On Mar 9, 7:33 am, zepolen <[email protected]> wrote:
> 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.

That's good for logging, but that would require hitting postgres on
EVERY page view... and would also have issues on a clustered system
( where READ and WRITE dbs need to sync ).



--~--~---------~--~----~------------~-------~--~----~
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