• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hi all and LiveCloud team...

Just a quick question about BatchSync - I am using cdb_batchSync to update the cloud database from the local database at certain intervals... 
It certainly does the job, BUT... it seems to be a 'blocking' command, meaning that everything in the app stalls until the command completes.

Is there a 'non-blocking' version of this, or am i doing this wrong?

this is my algorithm for syncing the entire db in either direction:

command syncDB pSource
   local tTableNames, tTableID, tInputA, tMessage
   put cdb_tableNames() into tTableNames
   repeat for each line tTable in tTableNames
       put cdb_tableID(tTable) into tTableID
       put "*" into tInputA[tTableID]["cdbRecordID"]
       put pSource into tInputA[tTableID]["source"]
       put true into tInputA[tTableID]["allowDeletes"]
       put false into tInputA[tTableID]["detectCollisions"]
   end repeat
   get cdb_batchSync(tInputA)

   if cdb_result() is not true then
       put "Error syncing cloud <-> local database: " & cdb_result("response"into tMessage
       answer tMessage
   end if
end syncDB

I think it may just be a bit too complex to try and maintain a system that flags changes and only syncs them, not in the least as the data is relational involving multiple tables and is still being developed, so i would prefer a system that would just sync everything 'in the background' if that were possible... 

As it stands, the process to sync does not appear asynchronous and blocks the interface - grateful for any advice/tips (or if appropriate a feature request for an asynchronous sync!)

Many thanks
Hi Stam,

Sync is blocking as things are today. I have some thoughts on how the performance could be improved. One idea we have bounced around is moving heavy cloud calls to a separate process. We developed that technology many years ago and use it in our backend. That does come with its own challenges though. Racing conditions would apply and pose a new level of complexity.

The other thought is to sync as efficiently as possible. For example, if we are syncing from local to cloud, we could do a local local query for records that have a modified date of a certain value (like today's changes as one example). Or, you could track your last sync date and make that the look up value. Then, sync only those records. This would be very efficient and save a lot of time.

While this is not built into the API today, you have all the power to do the query now and sync the results with what is available today.


Forum Jump:

Users browsing this thread: 1 Guest(s)