I'm attempting to build a live-updated system in php-mysql (and jQuery). The question I have is if the approach i'm using is good/correct or if i should look into another way of doing it:
Using jQuery and AJAX i have made:
setInterval(function() {
Ajax('check_status.php');
},4000);
in check_status.php i use memcache, to check if the result is either 1 or 0
$memcache = new Memcache;
$memcache->connect('127.1.0.1', 11211) or die ("");
$userid.$key = md5($userid."live_feed");
$result = $memcache->get($userid.$key);
if($result==1) {
doSomething();
}
The idea is that user A does something, and that updates the memcache for user B. The memcache is then being checked every 4 seconds via jQuery, and that way i can do a live_feed to user B.
The reason i use memcache is to limit the mysql_queries and thereby limiting the load on the datbase.
So the question is. Am i totally off here ? Is there a better way of doing this, to reduce the server load ?
Thank you