Madhur Ahuja
Madhur Ahuja

Reputation: 22701

Sync Algorithm Pattern

Let's say I have two sources: A and B. For example, both are disparate data stores for storing TODO lists.

How do I build an algorithm for an operation which ensures the both sources are synced ?

Do I just copy A to B and then copy B to A eliminating duplicates (assuming there is a primary key ID to eliminate duplicates)

Upvotes: 0

Views: 136

Answers (1)

Gangnus
Gangnus

Reputation: 24464

  • For items of both lists you should have set the time of the last sync.
  • During the next sync you work only with sublists of items, which appeared after the last sync time.
  • Yes, for these sublists the simple double-, or n-sided join will be enough.
    • The n-sided sync is more interesting. The better way will be to create a star system - where the syncs are done each time between the end list and the core list. The core list could be that one on server, the end lists will be these set and shown by UI.

Upvotes: 2

Related Questions