Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 724
mihatel Avatar asked Jan 17 '17 10:01

mihatel


People also ask

When should I use Core Data?

Use Core Data to save your application's permanent data for offline use, to cache temporary data, and to add undo functionality to your app on a single device. To sync data across multiple devices in a single iCloud account, Core Data automatically mirrors your schema to a CloudKit container.

Do I need caching?

Caching is a key component to the performance of any system. It ensures low latency and high throughput. A cache is a backup of primary data storage; It has a limited amount of space. It is faster to retrieve data from a cache than the original data source like databases.

Why is cache required?

A cache's primary purpose is to increase data retrieval performance by reducing the need to access the underlying slower storage layer. Trading off capacity for speed, a cache typically stores a subset of data transiently, in contrast to databases whose data is usually complete and durable.


1 Answers

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

like image 89
Giuseppe Lanza Avatar answered Oct 11 '22 22:10

Giuseppe Lanza