Jump to content

Last Active


Muncey

Recommended Posts

If i was to make a last active field in a members table in my database and had it update the field every page they went on, would this effect anything like speed?

 

I was just thinking if say 100 people are using it at the same time and it's updating the database EVERYTIME someone clicks on a different part of the site, it may get a bit slow or something?

 

Will this happen or is it fine to do this?

Link to comment
https://forums.phpfreaks.com/topic/60615-last-active/
Share on other sites

generally speaking, one sets an accuracy interval.  that is, it only updates the last active field in the database if the last recording took place x or more (minutes, hours, days) ago.  you update their last active in the database once they login, and set a session variable with that timestamp.  check the timestamp on every page they go to, and update the database again ONLY IF the timestamp is x or more interval old.  update that timestamp again.

 

in this way, you can grab everyone whose last active field was x or less interval old - it means they're online as accurately as the system can know.  increase the interval, you decrease the accuracy (because its updating less frequently).  this saves on resources a little more, for relatively little loss in accuracy (at, say, a 5 minute interval).

Link to comment
https://forums.phpfreaks.com/topic/60615-last-active/#findComment-301570
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.