简体   繁体   English

OS X App。哪种方式是存储数据的最佳方式?

[英]OS X App. Which is the best way to store data?

In a os x app, which is the best way to store hundreds of user record with a lot of information for each record? 在os x app中,这是存储数百个用户记录的最佳方式,每条记录包含大量信息?

I know that i can use CoreData, SQLite, Realm, plist or other solution. 我知道我可以使用CoreData,SQLite,Realm,plist或其他解决方案。 Which is the most compatible (i think for example for a web use) and clean/light/fast method/type of database to store data ? 哪个是最兼容的(我认为例如用于Web使用)和干净/轻/快的方法/数据库类型来存储数据?

thank 谢谢

Core Data is written by Apple to be used in Cocoa based applications. Core Data由Apple编写,用于基于Cocoa的应用程序。 It is already included on the operating system, has 10 years of development behind it and is used in hundreds of thousands of applications on the app store already. 它已经包含在操作系统中,已经有10年的发展历史,已经在应用程序商店中的数十万个应用程序中使用。

Using a third party library has tremendous risks associated with it. 使用第三方库存在巨大的风险。

I always recommend using Core Data on iOS and OS X because it is written by Apple, has a fully supported team of developers behind it and is a mature code base. 我总是建议在iOS和OS X上使用Core Data,因为它是由Apple编写的,有一个完全支持的开发团队,并且是一个成熟的代码库。

Using raw SQLite is possible but you will not get the same performance benefits as you will with Core Data. 使用原始SQLite是可能的,但是您将无法获得与Core Data相同的性能优势。

Realm is focusing on the wrong things. Realm专注于错误的事情。 Their data migration system is scary, they focus on raw speed when they need to be focusing on the overall picture. 他们的数据迁移系统很可怕,当他们需要关注整体情况时,他们会关注原始速度。 They might be targeting mobile but I do not agree with their goals. 他们可能会定位移动广告,但我不同意他们的目标。

Hundreds of records is not hard for any database system. 对于任何数据库系统来说,数百条记录并不难。 It is when you get to 10s of thousands of records on a device that many of them start to fall down due to memory pressure (even on OS X). 当你在一台设备上获得数以万计的记录时,由于内存压力,许多记录开始下降(即使在OS X上)。

Core Data is designed to help with the memory pressure. 核心数据旨在帮助解决内存压力。 I am not aware of any third part framework that will do so. 我不知道任何第三方框架会这样做。

I think the most important thing is to compare Realm with the other database. 我认为最重要的是将Realm与其他数据库进行比较。 Realm use its own core and the others are based on SQLite (CoreData use SQLite). Realm使用自己的核心 ,其他的基于SQLite (CoreData使用SQLite)。 Realm is the first database designed for mobile use. Realm是第一个专为移动使用而设计的数据库。 So with your case ( OSX ) you must consider if your app have the same functionning as mobile App: device restrictions. 因此,对于您的案例( OSX ),您必须考虑您的应用程序是否具有与移动应用程序相同的功能:设备限制。

Realm: 领域:

  • Very fast methods: see example here 非常快的方法:见这里的例子
  • Rapid execution: see benchmark here , yes thousands of user records! 快速执行: 在这里查看基准测试,是成千上万的用户记录!
  • Light: the embeded database less than 1MB Light:嵌入式数据库小于1MB

  • But in beta state. 但处于测试状态。 This mean that they are constantlyy in development 这意味着他们不断发展

SQLite: SQLite的:

the "lite" in the name mean it's a light database. 名称中的“精简版”意味着它是一个轻量级的数据库。 You have many libraries available in github to help you, full documentation and full examples. 您在github中有许多库可以帮助您,完整的文档和完整的示例。

Personnaly, I use Realm for My OSX App and despite it being in a beta state, I have all the features I need. Personnaly,我使​​用Realm for My OSX App,尽管它处于beta状态,但我拥有我需要的所有功能。 Realm is faster than CoreData and save me thousand of lines of code and months of work. Realm比CoreData更快,节省了数千行代码和数月的工作量。 :) :)

I hope that this will help you. 我希望这会对你有所帮助。

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

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