Question

I use longpolling technique for a notification system..Here the longpolling works by checking the unique id of the database table..If it is greater than the last changed id then the data is fetched..That's working good...

I wonder how to implement the longpolling technique to get the value of any rows that's been recently updated and deleted...The traditional shortpolling will eventually do it by poking the database from time to time... But in longpolling the request is kept open..Suppose I have 4 rows inserted...

id name body

1    A  blah
2    B  blah
3    C  blah
4    D  blah

If now there is a change on last inserted row like...

4    D  abcd

The longpolling technique wont fetch the updated portion..

or if the row with id 2 is deleted..Then also it won't work...

Can anyone suggest a method? Not using shortpolling..Because I don't want it that way....

Was it helpful?

Solution

You should add a new column named "revision". Revision is an autoincrement per "action", not per row.

It must me a normal index.

So you start like this:

Id Name Revision
1 aaaa.   1
2 bbbb.   2
3 cccc.    3
4 dddd.   4

Then when you update row 4 revision field should be 5 then if update row two, revision on row 2 should be 6.

For delete make a logical delete and also update the revision on that row and that should make the trick.

You return sorted by revision.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top