How to cache images only in disk using Kingfisher?

Viewed 12487

I am using Kingfisher library for downloading and caching images. I am facing some issues in the implementation:

  1. Are the images cached in both memory and disk?

  2. Is there any provision to cache images only on disk?

I have already read multiple posts regarding this, but couldn't find any solution.

3 Answers

If anyone looking for answer for downloading images explicitly and caching the same without using imageView the sample code is:

ImageDownloader.default.downloadImage(with: imgUrl, retrieveImageTask: nil, options: [], progressBlock: nil) { (image, error, url, data) in
                    print("Downloaded Image: \(url)")
                    //cache image:
                    if let image =  image, let url = url {
                        ImageCache.default.store(image, forKey: url.absoluteString)
                    }
                }

reference: https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet

Related