Skip to content

rallahaseh/RACaching

Repository files navigation

RACaching

CI Status Version License Platform

The purpose of the library is to abstract the downloading (images, pdf, zip, etc) and caching of remote resources (images, JSON, XML, etc) in-memory.



Usage

Import the framework

import RACaching

Extend RAURLObserverProtocol to the class and define a RAResourceManager, which loads all the resources you need from http/https.
Resource Manager:

  • Checks where corresponding resource for a URL in cache using cacheManager, if the resource is not found it checks if already downloading by the downloadsManager.
  • If the resource is not found then it creats resource and initialises download for that resource with adding observers for that resource.
  • If the resource is found in cache it sends the data back to the observer.
  • If the resource is found in the downloadsManager then it adds the observer to the list of resource observer.

Then use

open func getDataFor(_ urlString:, withIdentifier identifier:, withUrlObserver observer:)

Where it checks if the resource of the URL exists or not to creates new resource if not, the identifier here to add observers to a resource and delete it if object does not need data and the observer communicate the status of data fetch from Cache or Server

Installation

RACaching is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RACaching'

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

rallahaseh, rallahaseh@gmail.com

License

RACaching is available under the MIT license. See the LICENSE file for more info.

About

The purpose of the library is to abstract the downloading (images, pdf, zip, etc) and caching of remote resources (images, JSON, XML, etc) in-memory.

Resources

License

Stars

Watchers

Forks

Packages

No packages published