8/4/2016 9:03:48 AM
LinkedIn Makes Rocket Data Open Source So You Can Cache Data in Your iOS Apps Too
LinkedIn App,Rocket Data,loadFromCache
https://appdevelopermagazine.com/images/news_images/Linked-in-Rocket-Data-Open-Source-App-Developer-Magazine_oldrkeov.jpg
App Developer Magazine

LinkedIn Makes Rocket Data Open Source So You Can Cache Data in Your iOS Apps Too



Peter Livesey Peter Livesey in iOS Thursday, August 4, 2016
15,711

Last year, LinkedIn began rewriting the LinkedIn flagship mobile application. The existing app had a number of challenges and hadn’t received a significant overhaul in some time. So we wanted the new version to not only look and feel updated, but also to have powerful infrastructure backend to support it.

As a part of that effort, we wanted a caching system that would present content to the user while data was loading from the network. Core Data, a commonly used modeling and database framework provided by Apple, offers one potential solution. Core Data is a powerful framework, but it pays for its power with complexity, and the framework is notorious for crashing applications when something goes wrong.

We also wanted to use immutable models, and Core Data’s programming model relies on mutability. We then looked at some other options, like a simple URL cache, Realm, or just serializing the models to disk, but none of these solutions addressed our requirements. 

So, we decided to develop our own caching solution, building Rocket Data, which is a non-blocking, immutable model management system with a persistent synchronization layer. And we recently announced that we open sourced it (Rocket Data on Github) as well.
 
Rocket Data has a simple API which easily hooks up to key-value stores and can use any cache. Each view controller has a reference to one or more data providers. There are two types of data providers: regular data providers and collection data providers. The data is easy to consume with simple accessors in both providers and access to the data is instant, since the models are always kept in memory.

Here’s an example application run to show how data flows through Rocket Data:


- The view controller calls loadFromCache on the data provider. This call is asynchronous so it will not block the main UI thread. When the data returns, the view controller is notified and it will rerender.

- The view controller receives fresh data from the server. The view controller sets this data on the data provider. The data provider then lazily propagates this to the cache and Consistency Manager, again on a background thread.

- Later in the application execution, a model is changed which affects our view controller. The Consistency Manager will notify the data provider which will update its data and notify the view controller so it can rerender.

By using Rocket Data, we’ve been able to easily add caching to all features within the new LinkedIn mobile app with very little additional work from developers. The cache and data providers are automatically kept consistent across screens, and we’ve never needed to add code for any migrations.

We believe other products could benefit from Rocket Data’s flexibility to work with multiple modeling and caching solutions and are looking forward to hearing how it is used by the community.



Read more: https://engineering.linkedin.com/blog/2016/07/rock...

100 Questions and Answers to help you land your Dream iOS Job: or to hire the right candidate!

This guide titled, "100 Questions and Answers to help you land your Dream iOS Job" can help you through some further questions related to landing a job related to iOS. With 100 Questions and Answers categorized by seniority and with reviews from some of the top iOS engineers worldwide, this book will level up how you make interviews for your favorite platform.

The Latest Nerd Ranch Guide (3rd Edition) to Android Programming

Write and run code every step of the way, using Android Studio to create apps that integrate with other apps, download and display pictures from the web, play sounds, and more. Each chapter and app has been designed and tested to provide the knowledge and experience you need to get started in Android development.

Starting your own app business?

How to create a profitable, sustainable business developing and marketing mobile apps.


This content is made possible by a guest author, or sponsor; it is not written by and does not necessarily reflect the views of App Developer Magazine's editorial staff.


Comments

There are no comments yet, be the first to leave your remarks.

Leave a Reply