CachyKit
A Caching Library is written in Swift that can cache JSON, Image, Zip or AnyObject with expiry date/TTYL and force refresh.
Nice threadsafe expirable cache management that can cache any object. Supports fetching from server, single object expire date, UIImageView loading etc.
Installation
Cocoapods
CachyKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:
then run
$ pod repo update
$ pod install
Features
- [x] Asynchronous data downloading and caching.
- [x] Asynchronous image downloading, caching and showing.
- [x] Expiry date/time for all the object individually.
- [x] Multiple-layer hybrid cache for both memory and disk.
- [x] Fine control on cache behavior. Customizable expiration date and size limit.
- [x] Force refresh if needed.
- [x] Independent components. Use the Cachy or CachyLoader system separately as you need.
- [x] Can save JSON, UIImage, ZIP or AnyObject.
- [x] View extensions for
UIImageView
. - [x] Indicator while loading images.
Usage
If you want to download and cache a file(JSON, ZIP, UIImage or any type) then simply call with a url
You can also cache with URLRequest
if you want set expiry date for each object
Clear all cache
CachyLoader has also UIImageView extension.
It will download, cache and load UIImage into your UIImageView
CachyLoader is also configurable, by calling function CachyLoaderManager.shared.configure()
expiryDate parametre takes
- .never to never expire the cache object
- .everyDay to expire at the end of the day
- .everyWeek to expiry after a week
- .everyMonth to set the expiry date each month
- .seconds to set the expiry after some seconds
Without CachyLoader
To cache using CachyLoader is the easiest way to do, but if you want manage your caching, sycning and threading CachyKit also supports that.
Configuration
Here is how you can setup some configuration options
Adding/Fetching objects
If you want to add or fetch an object you just follow these simple steps: