简体   繁体   English

管理核心数据iCloud事务日志

[英]Managing Core Data iCloud Transaction Logs

I am using iCloud with Core Data, based on the SQLite "Library-style" application design as specified by Apple. 我正在使用iCloud和Core Data,它基于Apple指定的SQLite“库式”应用程序设计。 While the basic functionality works very well, I am concerned about the transaction logs and how they are managed. 虽然基本功能运行良好,但我担心事务日志及其管理方式。

While the database for my app is not large, it is very active and the core data stack is saved many times while the app is in use. 虽然我的应用程序的数据库不是很大,但它非常活跃,并且在应用程序正在使用时核心数据堆栈被保存了很多次。 I have noticed that a new transaction log is created for every core data save. 我注意到为每个核心数据保存创建了一个新的事务日志。 The end result is that I have a TON of transaction logs and they take up much more space than the actual database. 最终结果是我有一个TON的事务日志,它们比实际的数据库占用更多的空间。

1) Do the transaction logs ever get automatically pruned / coalesced, or will they continue to grow indefinitely, eventually numbering in the thousands and taking up many megabytes? 1)事务日志是否会被自动修剪/合并,还是会无限期地继续增长,最终会成千上万,并占用数兆字节? It seems that the only way to manually purge the transaction logs and recreate a .baseline archive would be to disable and then re-enable iCloud (removing the ubiquity container and starting fresh). 似乎手动清除事务日志并重新创建.baseline存档的唯一方法是禁用然后重新启用iCloud(删除无处不在的容器并重新启动)。 But this is obviously not a good solution. 但这显然不是一个好的解决方案。

2) My current architecture saves the core data stack often, even for minor changes. 2)我的当前架构经常保存核心数据堆栈,即使是微小的更改。 In general, this makes sense as my database is small and saving often ensures that the database file is always up-to-date. 通常,这是有道理的,因为我的数据库很小并且通常保存数据库文件始终是最新的。 However, given the above issues with transaction logs, I am thinking that I should perhaps minimize saves to the database. 但是,考虑到事务日志的上述问题,我认为我应该尽量减少对数据库的保存。 Maybe doing so on a timed basis and/or on app transition states. 也许是在定时和/或应用过渡状态下这样做。

3) Even if I minimize the number of transaction logs by reducing how often I save the database, there seems to be an issue here, as the logs will continue to grow in number over time. 3)即使我通过减少保存数据库的频率来最小化事务日志的数量,这里似乎存在一个问题,因为日志将随着时间的推移而继续增加。 Eventually the benefit of the "transaction log" design will become a burden in terms of the amount of iCloud storage used and the initial iCloud sync as a new device is added. 最终,“交易日志”设计的好处将成为使用的iCloud存储量以及添加新设备时初始iCloud同步的负担。

As Apple has provided very sparse information on iCloud and almost nothing in the form of "best practices", I would appreciate any insight from the community. 由于Apple提供了非常稀疏的iCloud信息,而且几乎没有提供“最佳实践”的形式,我很感激社区的任何见解。

I filed a radar on this issue and received the following reply. 我就此问题提出了一个雷达,并收到了以下答复。 They noted that it should be working correctly in iOS 5.1, though I have not yet verified this myself. 他们指出它应该在iOS 5.1中正常工作,尽管我自己还没有验证过。

A clarification for any who might misunderstand the following. 对任何可能误解以下内容的人的澄清。 The transaction logs will be cleaned up by the core data internals. 事务日志将由核心数据内部清理。 This is NOT something that should be performed by the application itself. 这不应该由应用程序本身执行。

Engineering has provided the following feedback regarding this issue: Engineering对此问题提供了以下反馈:

The transaction logs are intended to be deleted after all the active peers have had a chance to read them, and they exceed a threshold of space consumed. 在所有活动对等体都有机会读取它们之后,将删除事务日志,并且它们超过了消耗的空间阈值。 There was a previous issue that prevented the devices from correctly doing so. 之前的问题阻止了设备正确执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM