简体   繁体   English

使用SDWebImage中的URL将图像保存到缓存

[英]Save image to cache with URL in SDWebImage

I meet a demand that my app will upload some image to web service, and later my App has big chance to download it with URL by SDWebImage when my App refreshes UI with after fetching data from web service. 我满足了我的应用程序将一些图像上传到Web服务的要求,后来,当我的应用程序从Web服务中获取数据后刷新UI时,我的应用程序很有可能通过SDWebImage通过URL下载它。
Since the image is uploaded by my app, so I think I should save it in cache of SDWebImage with a URL, so later when I use SDWebImage to load the image by the url, it will pick it up from cache, better for performance. 由于图像是由我的应用上传的,因此我认为我应该使用URL将其保存在SDWebImage的缓存中,因此稍后当我使用SDWebImage通过url加载图像时,它将从缓存中拾取图像,从而提高性能。

If you're getting images from your app (and server) then don't store images to cache else it will become complex to handle. 如果要从应用程序(和服务器)获取图像,则不要将图像存储到缓存中,否则处理起来会很复杂。 In good case, you should always fetch images from the server using SDWebImage if its already in cache, it will load directly from there. 在良好的情况下,如果SDWebImage已经在缓存中,则应始终使用SDWebImage从服务器获取图像,它将直接从那里加载。 No need to handle an extra case. 无需处理额外的情况。 While loading new images from server, you can always show a place holder to make your UI better. 从服务器加载新图像时,您始终可以显示一个占位符以改善UI。

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

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