Memcache is the PHP interface to memcached (memory object caching)
It really isn't the right tool for the job. He's obviously storing the data as a key - this probably would be faster than hitting a database, but it still sucks.
If you're looking to implement some sort of real-time chat solution I would recommend looking into the following techologies. Read up on them and you'll find a solution which may suit your needs.
- Flash (AS3) sockets with a chat server OR
- HTML5 Web Sockets OR
- COMET (Facebook uses this.)
Flash (AS3) sockets:
There are many ways to build an Actionscript 3 chat system. It's actually pretty easy if you use one of the many existing solutions out there. IE: Smartfox. You can even use the External Interface to trigger Javascript events every time a message is received.
HTML5 Web Sockets
As support for this is pretty flakey I recommend you look into degrading gracefully with Flash. Example of a library you can use: https://github.com/gimite/web-socket-js/
COMET/Long polling
This is quite an interesting approach. Effectively what you're going to be doing is "blocking" the HTTP request server-side by not returning any data until some is available EG:
while(!d = data()) {
// no data...
}
return "{data : d}"
Your browser will in most cases just sit there happily waiting for something to happen. Once data is received the browser will close the connection - this is when you process the data, and then re-open a connection (fire off a new ajax request) so that you are listening for new events!
To accomplish this I recommend using a non-blocking server such as Tornado (http://www.tornadoweb.org/)