SDWebImage change cacheMaxCacheAge

醉酒当歌 提交于 2019-12-11 03:04:16

问题


How I can change a static value cacheMaxCacheAge when I use SDWebImage? What way is good? I need to cache images for 5 minutes.


回答1:


In SDWebImage 5.0+ maxCacheAge renamed to maxDiskAge. You can set maximum caching time in seconds like this.

Objetive-c

[SDImageCache sharedImageCache].config.maxDiskSize = 60 * 5; //5 minutes

Swift 4+

SDImageCache.shared.config.maxDiskAge = 60 * 5 //5 minutes

Reference link: https://github.com/SDWebImage/SDWebImage/wiki/5.0-Migration-guide




回答2:


SDWebImage is providing maxCacheAge property to set the maximum caching time in seconds. We can use shared instance method to access this property.

[SDImageCache sharedImageCache].config.maxCacheAge = 60 * 5; //5 minutes


来源:https://stackoverflow.com/questions/28549211/sdwebimage-change-cachemaxcacheage

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