Skip to content

keshavx11/KBCachier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KBCachier

An easy to integrate and use api cache library

Swift version CocoaPods Compatible Platform License PRs Welcome

This library provides an async image, JSON and Data downloader with cache support. For convenience, Extension for UIImageView has been added. Download Data asynchronously, cache response in memory, set max cache size and more with KBCachier!

Features

  • Cache Image, JSON or any other Data from APIs
  • Set maximum cache size
  • Parellel requests
  • Choose thread for api calls
  • Customizable

Requirements

  • iOS 10.0+
  • Xcode 10.0

Installation

CocoaPods

You can use CocoaPods to install KBCachier by adding it to your Podfile:

platform :ios, '10.0'
use_frameworks!
pod 'KBCachier', :git => 'https://github.com/keshavx11/KBCachier.git', :tag => '0.0.1'
github "keshavx11/KBCachier"

Manually

  1. Download and drop KBCachier folder in your project.
  2. Congratulations!

Usage

import KBCachier

// Configure Cachier
class func configureCachier() {

    // Max cache size 10 MB
    Cachier.shared.isInMemoryCacheEnabled = true
    Cachier.shared.maxCacheSize = 10485760

    // Set log level
    Cachier.shared.logLevel = .warning

    // Set dispatchQueue for making api calls
    Cachier.shared.dispatchQueue = DispatchQueue.global(qos: .userInitiated)

}

// Get JSON data
func getJSON() {
    Cachier.shared.fetchJSONData(forUrl: YOUR_URL, completion: { (response: Any) in
    
    }, error: { errorString in

    })
}

// Download Image and set to image view directly
func downloadImage() {
  self.downloadTask = self.imageView.setImage(withUrl: url, placeholder: nil, completion: { (success) in

  })
}

// Cancel Download task
self.downloadTask.cancel()
    

LICENSE

MIT License (see LICENSE)

Contribute

We would love it if you can contribute to KBCachier

Author

Keshav Bansal – @LinkedInkeshav_x11@yahoo.co.in

About

An easy to integrate and use api cache library

Resources

License

Stars

Watchers

Forks

Packages

No packages published