swiftcachingcore-dataalamofirehaneke

Do I need cache if using CoreData


First of all I'm new in ios/swift...

I need to have offline mode of my app.

I'm using Alamofire for all networking getting json, convert to objects and save into the DB (Core-Data). Wanted to know do I need to have additional cache in between (like: Haneke, or DataCache) in case no internet connection or getting from CoreData?

Is DB request fast/convenient enough?


Solution

  • CoreData is very fast (if correctly used). I don't believe it would be necessary to have an additional cache layer.

    It would be just a duplication of data that you already have stored in your DB.

    By the way all depends from your project use cases. I would not rely on temporary cached data if my app must work without internet connection.

    To give you an idea of core data performances so that you can choose what works best for you: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/Performance.html