How to save image permanently by using sdwebimage?

只谈情不闲聊 提交于 2019-12-11 16:57:11

问题


I'm the new on swift. I have a question how to save image from url into permanent cache. Since URL live for only 30min and is expired after 30min, I'm using sdwebimage and saving image in disk and memory cache. My code is like the below. and it's working well. Problem is that sometimes image is not loaded because of unknown issue. I guessed that image is not saved permanently in cache..This is just my guess. So, I'd like to save image permanent cache. How can I do this? Or Is there anyone know why this symptom is observed?

My code :

cell.imageView.sd_setImage(with: URL(string: url), placeholderImage: nil)

回答1:


I guess it should not happen when you are saving it already, maybe you are refreshing it somewhere in your project.

Condition 1: May you have set the refresh cache code.

imgView.sd_setImage(with: URL(string: yourString!), placeholderImage:UIImage(named: "placeholder_icon"), options: .refreshCached)

or

SDImageCache.shared().clearMemory()
SDImageCache.shared().clearDisk()

Condition 2: May you have set the refresh cache time like

SDImageCache.shared().config.maxCacheAge = 60 * 60 * 24;

If your case is not from above two conditions, I am eager to know the answer.



来源:https://stackoverflow.com/questions/48623103/how-to-save-image-permanently-by-using-sdwebimage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!