Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ensembles

 Ensembles

Core Data Syncing Made Easy

Avatar for JosselinOudry

JosselinOudry

October 06, 2016

Other Decks in Programming

Transcript

  1. Core Data Synchronization Ensembles is a framework for : Backend-agnostic

    Peer-to-peer synchronization of Core Data persistent stores.
  2. Transaction Logs Ensembles breaks down each persistent store into a

    series of transactions A transaction is : a CRUD operation NSDictionary/JSON : key-value pairs of an object’s property names and values
  3. { "type" : "insert", 
 "id" : "CAR12345", 
 "manufacturer"

    : "Mazda", 
 "model" : "626", 
 "year" : 2003, 
 "owner" : "OWNER54355" 
}
  4. Many CRUD transactions are made in a single save to

    the data store. All of these transactions get bundled up in files known as transaction logs. A timestamp is applied to each set of changes, so that they can be ordered later, and the files are what get uploaded to the cloud. In other words, Ensembles records the changes to the data store — the so-called deltas — rather than copying the whole data store itself. By only transmitting the changes, the quantity of data transfered is considerably less, and it is also easier to combine changes from different devices: they just get played back in the same order as their timestamps dictate.
  5. E L M ensemble = [[CDEPersistentStoreEnsemble alloc] initWithEnsembleIdentifier:kMyEnsembleIdentifier persistentStoreURL:sqliteStoreURL managedObjectModelURL:modelURL

    cloudFileSystem:cloudFileSystem]; [ensemble leechPersistentStoreWithCompletion:^(NSError *error){}]; [ensemble mergeWithCompletion:^(NSError *error){}];
  6. How to add Ensembles to your Core Data App ?

    No changes to existing Core Data stack Automatic de-duplication Automatic merging and migration
  7. Ensemble vs The Rest - iCloud (since 2011). Buggy, Black

    Box manual deduplication, no way to resolve conflicts. Apple is abandonning the automatic Core Data synching. - Cloud Kit (>=iOS8).No built-in support for Core Data. More «open » than iCloud but very raw implementation, No automatic synching, dedup,... - DropBox DataStore API : No built-in support for CoreData. Users have to have a dropbox account. - Simperium : You have to pay for storage...
  8. Recap Ensembles 1.0 Open Source(MIT), Core Data sync Peer-to-peer Backend

    agnostic Ensembles 2 : Commercial for more complex data stores.