Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I thought about 2 approaches and already implemented 1 of them, but it's quite complicated and I fear a bit about it'sits performance and error-proneness.
I thought about 2 approaches and already implemented 1 of them, but it's quite complicated and I fear a bit about it's performance and error-proneness.
I thought about 2 approaches and already implemented 1 of them, but it's quite complicated and I fear a bit about its performance and error-proneness.
P.S. would also appreciate reading recommendations about this (maybe as a comment), any good resource about sync strategies. I'm using Scala, Play 2.4 and Akka in some parts so a recommendation in this direction would also be very useful.
P.S. would also appreciate reading recommendations about this (maybe as a comment), any good resource about sync strategies.
P.S. would also appreciate reading recommendations about this (maybe as a comment), any good resource about sync strategies. I'm using Scala, Play 2.4 and Akka in some parts so a recommendation in this direction would also be very useful.
Client sends all its items to server (this could be refined by filtering items that need create/update/delete, but for now it sends everything). Items have a server last update timestamp and flag if it's marked to be deleted.
Server queries all the items for the user
ProgramaticProgrammatic algorithm that goes through all the items checking timestamps in order to determine if the item can be updated/deleted or not. If the last server update timestamp in the client's item is different than the one stored in the server (meaning, someone else updated the item in between) the update/delete is rejected. I build many lists here, one of items that have to be inserted (items are not in the server's query result), items that are to be updated, items that are to be deleted, items that can't be updated because the timestamp is different, items that can't be deleted because the timestamp is different.
Transaction for inserts/updates/deletes, for which I use lists constructed in 3.
Query to get again all the items for the user.
Send result of this query to client, together with the lists of items that couldn't be updated or deleted built in 3., so client knows what failed.
Client sends all its items to server (this could be refined by filtering items that need create/update/delete, but for now it sends everything). Items have a server last update timestamp and flag if it's marked to be deleted.
Server queries all the items for the user
Programatic algorithm that goes through all the items checking timestamps in order to determine if the item can be updated/deleted or not. If the last server update timestamp in the client's item is different than the one stored in the server (meaning, someone else updated the item in between) the update/delete is rejected. I build many lists here, one of items that have to be inserted (items are not in the server's query result), items that are to be updated, items that are to be deleted, items that can't be updated because the timestamp is different, items that can't be deleted because the timestamp is different.
Transaction for inserts/updates/deletes, for which I use lists constructed in 3.
Query to get again all the items for the user.
Send result of this query to client, together with the lists of items that couldn't be updated or deleted built in 3., so client knows what failed.
Client sends all its items to server (this could be refined by filtering items that need create/update/delete, but for now it sends everything). Items have a server last update timestamp and flag if it's marked to be deleted.
Server queries all the items for the user
Programmatic algorithm that goes through all the items checking timestamps in order to determine if the item can be updated/deleted or not. If the last server update timestamp in the client's item is different than the one stored in the server (meaning, someone else updated the item in between) the update/delete is rejected. I build many lists here, one of items that have to be inserted (items are not in the server's query result), items that are to be updated, items that are to be deleted, items that can't be updated because the timestamp is different, items that can't be deleted because the timestamp is different.
Transaction for inserts/updates/deletes, for which I use lists constructed in 3.
Query to get again all the items for the user.
Send result of this query to client, together with the lists of items that couldn't be updated or deleted built in 3., so client knows what failed.