I have a Section in my website called Recent Updates. in that I will show the latest 5 updates at first when the page is rendered.
When a New update is done at real time, the new update will be appended to the top of the updates list and the last one will be deleted.
My approach:
For this problem, what im doing is, First i renders the page with last 5 recent updates. I am fetching updates from database. When a update is made in realtime, it will be stored in database with flag = 0.
To find out whether any update is made, I have a javascript which calls the ajax page every 4 seconds. The ajax page checks in the db whether any records with flag=0 is present. If any of its there, then it will return back the update with flag=0 and set that flag to 1.
Problem:
It is working fine on a single system. But I havent tested on multiple system at same time.
I fears, the each update can be viewed only by single user
and its flag is set to 1. So the other users may not get it.
Is there any alternate approach in solving this issue?. May be changing the query or something may yield goodness. Expecing help from experts here.. Any help will be appreciated.