即使未进行任何更改,CloudKit数据库也会在每次同步时生成一个新的更改令牌

时间:2019-05-01 14:33:34

标签: ios synchronization cloudkit

我的CloudKit数据库每次请求更改时都会生成一个新的更改令牌-即使没有进行任何更改。

我很高兴发布代码,但是我认为这与问题无关,并且我不想压倒一切。我在一些控制台输出下面发布了用于调试的信息,以显示我正在保存和使用令牌,但是数据库每次同步都发送新的令牌。如您所见,我没有更改数据库中的任何内容。作为参考,记录区每次都不发送新令牌,仅发送数据库。

这是预期的行为吗?如果没有,对为什么/如何发生有任何想法吗?

 SyncOperation fires on Simulator, Private 
☣️ FetchDatabaseChangesOperation fires 
☣️ FetchDatabaseChangesOperation changeTokenUpdatedBlock
☣️ token used: <CKServerChangeToken: 0x7b04000029f0; data=AQAAAWpzvY7V>
☣️ server says: <CKServerChangeToken: 0x7b0400025330; data=AQAAAWpzvoVX>
☣️ saving token: <CKServerChangeToken: 0x7b0400001130; data=AQAAAWpzvoVX>
☣️ FetchDatabaseChangesOperation complete  ⏱0.26
 FetchRecordZoneChangesOperation no changes 
 ModifyObjectsOperation - no changes 
 UploadChangesOperation - no uploads 
 ModifyObjectsOperation - no changes 
 SyncOperation complete  ⏱0.28

☁️  Pull to refresh fires

 SyncOperation fires on Simulator, Private 
☣️ FetchDatabaseChangesOperation fires 
☣️ FetchDatabaseChangesOperation changeTokenUpdatedBlock
☣️ token used: <CKServerChangeToken: 0x7b0400001f50; data=AQAAAWpzvoVX>
☣️ server says: <CKServerChangeToken: 0x7b0400001e90; data=AQAAAWpzvopq>
☣️ saving token: <CKServerChangeToken: 0x7b0400025350; data=AQAAAWpzvopq>
☣️ FetchDatabaseChangesOperation complete  ⏱0.24
 FetchRecordZoneChangesOperation no changes 
 ModifyObjectsOperation - no changes 
 UploadChangesOperation - no uploads 
 ModifyObjectsOperation - no changes 
 SyncOperation complete  ⏱0.25

☁️  Pull to refresh fires

 SyncOperation fires on Simulator, Private 
☣️ FetchDatabaseChangesOperation fires 
☣️ FetchDatabaseChangesOperation changeTokenUpdatedBlock
☣️ token used: <CKServerChangeToken: 0x7b0400001f50; data=AQAAAWpzvopq>
☣️ server says: <CKServerChangeToken: 0x7b0400000d00; data=AQAAAWpzvo3P>
☣️ saving token: <CKServerChangeToken: 0x7b0400026840; data=AQAAAWpzvo3P>
☣️ FetchDatabaseChangesOperation complete  ⏱0.13
 FetchRecordZoneChangesOperation no changes 
 ModifyObjectsOperation - no changes 
 UploadChangesOperation - no uploads 
 ModifyObjectsOperation - no changes 
 SyncOperation complete  ⏱0.13

编辑要添加:

如果我进入仪表板并获取这些更改令牌中的任何以来的更改,它会给我正确的响应,即没有更改:

iCloud Dashboard showing no changes occured

我不明白,如果没有新的更改,为什么它会生成新的令牌?

1 个答案:

答案 0 :(得分:0)

我也注意到了这一点。似乎CKDatabase将所有提取操作视为值得出售新令牌的数据库活动。这应该没问题,因为它不会在您的应用中引起任何副作用。只需确保即使没有任何更改,最新令牌也可以在本地持久保存。