Clicky

iOS Dev Nugget 212 Local Datastore as a Cache

.

Need to run a code review on your codebase? Hire me

Rather than a specific piece of code, I want to talk about a kind of "pattern" that I like to use.

With good connectivity for most iOS devices nowadays, I noticed there's a paradigm that works quite well for many types of apps.

Where applicable, use your app's local datastore as a temporary cache — be it Core Data, SQLite, plist or any other databases. This is only possible if you have a server side database/API which you can sync to.

I took a quick look at the top apps in the app store and can easily name a few types of apps that can work with this model, e.g. chat apps, Twitter apps, Facebook apps, news apps, podcasts apps. There are more and they tend to display content that is refreshed very often.

This gives you the advantage of having a single source of truth (the server) and if any goes wrong, you can just blow away your local datastore and rebuild it from the server.


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues