我想为多个组使用多个缓存方案,例如: 1 - 此图像组应该每60秒刷新一次。 2 - 除非发生内存警告,否则此映像组应永久存在。 我不知道如何使用AlamofireImage(或Kingfisher)这样的库来实现多个缓存程序。我写了这个代码,但它不能在文件夹中明确失效映像(我不想清除所有的缓存文件夹的内容):如何使用Kingfisher(或AlamofireImage)手动设置缓存中的图像的最大周期并清除过期的项目?
let downloader = ImageDownloader(name: "shortlived_image_downloader")
let cache = ImageCache(name: "shortlived_cache")
cache.maxCachePeriodInSecond = 60
cell.onPlayingImageView.kf.setImage(with: url,
placeholder: UIImage(named:"Placeholder_S"),
options: [.transition(ImageTransition.fade(0.25)),
.downloader(downloader),
.targetCache(cache)],
progressBlock: nil,
completionHandler: nil)
func clearKFShortLiveCache() {
let cache = ImageCache(name: "shortlived_cache")
cache.clearMemoryCache()
cache.cleanExpiredDiskCache()}
2017-05-30
Omnia