An easy to integrate and use api cache library
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!
- Cache Image, JSON or any other Data from APIs
- Set maximum cache size
- Parellel requests
- Choose thread for api calls
- Customizable
- iOS 10.0+
- Xcode 10.0
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"
- Download and drop
KBCachier
folder in your project. - Congratulations!
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()
MIT License (see LICENSE
)
We would love it if you can contribute to KBCachier
Keshav Bansal – @LinkedIn – [email protected]