-->

Sqlite 3 vs NSCoding Protocol

2020-07-24 06:07发布

问题:

Which is more efficient for storing cache data. I see Twitter for Mac stores blobs of information inside a sqlite file. Some apps implement NSCoding protocol.

Is there any advantage of one over another?

回答1:

The two are quite different. SQLite is a relational database, the stuff around NSCoding is an object serialization technique. The choice depends on your cache data. If your cache is a bunch of objects, I’d certainly go for NSCoding, as it’s very simple to work with, much simpler than raw SQLite. Once you have thousands of objects in the disk cache and don’t want to load all of them at once, you might have a better fit for SQLite.



回答2:

Rather than dealing with SQL complexity, you may want to give a try to something like CoreData than can store object-graphs pretty easily.

If you need to store binary data CoreData can also do this but you shall considerer data size when you specify the data model.

Check Marcus Zarra speech on this subject at :

  • http://ideveloper.tv/freevideo/details?index=17089146
  • http://ideveloper.tv/freevideo/details?index=17295063

You may find other interesting information on this one by Aaron Hillegass:

  • http://ideveloper.tv/freevideo/details?index=17081942