• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CDBCache sync from local to cloud
#1
Dear LiveCloud users,

I am a bit confused about how the CDBCache should be working. I may have the wrong understanding from the documentation and what I get with the code. Maybe someone can point me in the right direction.

My application starts after the login with checking to start with syncing updated records if authentication status with the cloud succeeds and then go into the first card, or just straight go to the first card if authentication status with the local database succeeds.


Code:
get cdb_auth(tEmail,tPassWord,"User")
put cdb_authStatus() into tAuthStatusA
if tAuthStatusA["cloud"] then
  cdb_loadTable
  ...
else
  if tAuthStatusA["local"] then
     cdb_loadTable
     ...
  end if
end if
...

The user can update records and these are applied to the local database first, and then synced to the cloud using cdb_batchSync(tInputA).
All have been working just fine when there is an internet connection, passing the cloud authentication at the start. I can use different devices and their local database is always synced via the cloud database. But when I put my laptop in airplane mode (no internet) it passes the local authentication and the call to cdb_batchSync isn't being processed. (This is testing in the development environment, working from within the LiveCode IDE.) I assumed from the documentation that the missed transactions, to sync the cloud database with the local changes (as the source), will be cached. When the application would start the next time, my laptop not being in airplane mode (so WITH an internet connection), the cached data update would then be applied to the cloud database. This never happens though.

Is there a different way I should work with this, keeping database content synced via the cloud across different devices (when sometimes a device is being used without an internet connection)? Any help to understand this better I would appreciate very much.
  Reply
#2
Hi Hendricus,

Thank you for your question about sync and the cache system.

The Cache is designed to capture CRUD calls should they fail or get interrupted due to a poor or missing internet connection. This system works very well for CRUD calls.

At one point we used to cache offline sync calls. But, this caused a fair amount of problems due to the complexity of a sync call. There are deletes and updates with a touch count that made caching syncs problematic.

At one point, we had a partially working model. When using it in the wild (NurseNotes.net), we found that many syncs could be cached. It would make the software feel sluggish processing in this case hundreds of thousands of records multiple times or with different variations. Syncs wheree the cloud was the source made no sense to cache as the communication with the cloud is essential to even understand which files were out of sync. The performance hit was not worth the convenience of trying to cache large amounts of data.

We concluded that it easy enough and more performant to check cdb_result() to see if any calls fail. This may be most important when doing a sync. If a NurseNotes sync fails due to no internet available we can track this and try again when the internet returns.

I reviewed our doc on cdbCache. I see that it lists sync as one of the calls that fit within its pervue. I'll update the doc and remove sync.

Please try checking the result with: if not cdb_result() then [code here to flag syncing for later].
  Reply
#3
Thank you, Mark. This is very helpful.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)