Not able to remove image cache entry using HanekeSwift

416 views Asked by At

I am using HanekeSwift to download an image from URL and set it in the UIImage.

I am doing it like .hnk_setImageFromURL()

The image URL gets updated with new image frequently and I need to download the new image. But as the image is already available in cache, the image is taken from the cache and not from the url fetch. In order to solve this I tried to remove cache entry for this key(i.e URL) using Shared.imageCache.remove(key: ).

Even after doing this the image is fetched from the cache and I do not see any network calls. Looks like the remove(key:) function is not working as expected.

Help me to find a solution for this issue.

1

There are 1 answers

1
Donal On

If you are cacheing image using image.hnk_setImageFromURL(URL) in that case you have to remove all cache for image instance ,but if you are cache image using with key value pair you can remove cache using it key.

example

If i cache image like

let imageCache = Shared.imageCache
imageview.hnk_setImageFromURL(URL) 

in above case you can remove cache using imageCache.removeAll() but if you are cache image like

imageview.hnk_setImage(UIImage(), key:"image") in that case you can remove using imageCache.remove(key: "image")

you can also cache image using imageCache.set(value: UIImage(named:""), key: "image") and remove cache using imageCache.remove(key: "image")