London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
15.3 C
New York
Monday, October 21, 2024

ios – Does CloudKit assure CKRecord.Reference is at all times legitimate?


I am contemplating utilizing CloudKit in my app (it would not use Core Information) and have learn as many supplies as I can discover. I have not totally grasped it but and have a fundamental query on CKRecord.Reference. Does CloudKit assure CKRecord.Reference worth is at all times legitimate? By legitimate I imply the goal CkRecord pointed by the CKRecord.Reference exists within the database.

Let’s take into account an instance. Suppose there are two tables: Account and Transaction:

Account Desk:

  AccountNumber Forex Charge
  ------------- -------- ----
  a1            USD      0.03

Transaction Desk:

  TransactionNumber AccountNumber Quantity
  ----------------- ------------- ------
  t1                a1            20

Now suppose consumer does the next:

  1. Consumer first deletes account a1 and its related transactions t1 on machine A. The machine saves the change to cloud.
  2. Then consumer provides a brand new transaction t2 to account a1 on machine B, earlier than the machine receives the change made in step 1 from cloud. Since a1 hasn’t been deleted on machine B, the operation ought to succeed regionally. The machine tries to avoid wasting the change to cloud too.

My questions:

Q1) Will machine B be capable to save the change in step 2 to cloud?

I hope it could fail, as a result of in any other case it could result in inconsistent knowledge. However I discover the next in CKModifyRecordsOperation doc (emphasis mine), which means CloudKit permits invalid reference:

Throughout a save operation, CloudKit requires that the goal document of the mum or dad reference, if set, exists within the database or is a part of the identical operation; all different reference fields are exempt from this requirement.

(BTW, I feel the truth that, when utilizing CloudKit, Core Information requires all relations should be elective additionally signifies that CloudKit cannot assure relation is at all times legitimate, although I feel that’s primarily a problem on consumer facet brought on by knowledge switch measurement. The above instance, nevertheless, is totally different in that it is a problem on cloud facet – the information on cloud is inconsistent).

I additionally discover the next within the doc. Nevertheless, I do not suppose it helps within the above instance, as a result of IIUC CloudKit can solely detect battle when the modifications on the identical document however the modifications in step 1 and step 2 are on totally different data.

As a result of data can change between the time you fetch them and the time you save them, the save coverage determines whether or not new modifications overwrite current modifications. By default, the operation stories an error when there’s a more moderen model on the server.

If the above understanding is appropriate, nevertheless, I do not perceive why the identical doc has the next requirement, which means CloudKit would not permit invalid reference:

When creating two new data which have a reference between them, use the identical operation to avoid wasting each data on the identical time.

Q2) Suppose CloudKit permits invalid reference on cloud facet (that’s, machine B efficiently saves the change in step 2 to cloud) , I ponder what’s the perfect observe to cope with it?

I feel the problem is totally different from the elective relation requirement in Core Information when utilizing CloudKit, as a result of in that case the information is constant on cloud facet and ultimately the consumer will obtain full knowledge. Within the above instance, nevertheless, the information on cloud is inconsistent so the consumer has to treatment it someway (though consumer has little data serving to it).

One strategy I consider is to keep away from the problem within the first place. My concept is to keep up a counter within the database and requires consumer to extend the counter (it isn’t Lamport clock. BTW, is it attainable to make use of Lamport clock on this case?) when making any change. This could assist CloudKit to detect battle (although I am unable to suppose out an excellent technique on how consumer ought to cope with it. A easy one is maybe to immediate consumer to pick one copy). Nevertheless, this strategy successfully makes use of cloud as a centralized server, which I believe is not the standard method how folks use CloudKit, and it requires purchasers to keep up native counter worth in varied conditions. I ponder what is the typical strategy? Am I lacking one thing?

Thanks for any assist.

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com