home > overview

Brian Deshong's Blog: Who's Online with PHP and Memcached




Brian Deshong has this new post on his blog today with an alternative method for doing the old standby "who's online" for your website.

Whenever you Google around for things like "Who's Online php", you'll find that a lot of the solutions are centered around using a database. However, is this really necessary? [...] One goal here: get Who's Online functionality off of the database. We'll explore a possible solution with Memcached that I've personally implemented, and thus far, it's been working great.

His alternative, using the memcache functionality that can be enabled in PHP, stores a "user ID" (either a real user ID or just some unique identifier) and their last activity time. This information is stored in a local file that can be queued each time the page it loaded. The other piece is a backend script that goes through this same file and clears out the old values. Depending on the size of the file/traffic of the site, this process could even be integrated into the same script that writes it.




click here to see original article or to find similar articles

 RSS DAILY HEADLINES

HEADLINES

Edwards to emerge from seclusion for speech

Aug. 9: Jennifer Palmieri, former staffer for John Edwards tells NBC's Jenna Wolfe that Elizabeth Edwards knew about her husband's affair since 2006, and is relieved the news is now public. (Today Show)In a return to the public stage, John Edwards has confirmed plans to talk politics a month after admitting to an extramarital affair. But his wife won't be at his side.


Australian police clear Indian doctor of involvement in terror (AFP)

Indian doctor, Mohamed Haneef, at a press conference in Bangalore in early August. Australian police have cleared Haneef of involvement in failed bomb attacks in Britain last year after a bungled 14-month probe(AFP/File/Dibyangshu Sarkar)AFP - Australian police have cleared an Indian doctor of involvement in failed bomb attacks in Britain last year after a bungled 14-month probe that is now the subject of a judicial inquiry.


Consumer spending flags, but confidence rises (Reuters)

A shopper walks past a store display in New York July 1, 2008. (Lucas Jackson/Reuters)Reuters - Personal income tumbled unexpectedly in July and inflation-adjusted spending shrank as government economic stimulus waned, but consumer spirits rose this month, a hint the economy may muddle through its woes.