繁体   English   中英

翠鸟缓存图像到磁盘

[英]Kingfisher cache image to disk

for url in status.storedPicURLS! {
            group.enter()
            print("🐷\(status.storedPicURLS)")
            KingfisherManager.shared.downloader.downloadImage(with: url, options: nil, progressBlock: nil, completionHandler: { (image, _, _, _) in
                print("🐶 \(image)")
                group.leave()
            })
        }
    }
    group.notify(queue: .main) {
        finished(list, nil)
    }

我可以在控制台中获取图像,但我无法在缓存中找到它们。

/Library/Developer/CoreSimulator/Devices/7AF33AA9-220E-4B54-9830-  AA94226C16E8/data/Containers/Data/Application/451F885E-1DFF-4E57-A0D7-B3DEC880DF8F/Library/Caches/

图像描述在这里

下载程序( ImageDownloader )与缓存无关。 如果要下载和缓存(以及稍后检索缓存的图像),则应使用manager方法: KingfisherManager.shared.retrieveImage而不是下载器独立。

请参阅文档中的以下摘录:

imageView.kf.setImage(with: url, completionHandler: { 
    (image, error, cacheType, imageUrl) in
    // image: Image? `nil` means failed
    // error: NSError? non-`nil` means failed
    // cacheType: CacheType
    //                  .none - Just downloaded
    //                  .memory - Got from memory cache
    //                  .disk - Got from memory Disk
    // imageUrl: URL of the image
})

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

检查cacheType的结果是什么。 它可能不存储在磁盘缓存中。

做这个:

        KingfisherManager.shared.downloader.downloadImage(with: url, options: nil, progressBlock: nil, completionHandler: {  (image, error, cacheType, imageUrl) in
            print("\(imageUrl), from cache: \(cacheType)")
            group.leave()
        })

粘贴输出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM