[英]how to expire cached nimbus network image
I'm having trouble with refreshing a nimbus image and not sure if I'm correctly removing the cached images. 我在刷新灵气映像时遇到问题,不确定我是否正确删除了缓存的图像。 After I upload a new image it still keeps showing the old image on refresh for a few minutes or more. 上传新图像后,它仍会在几分钟或更长的时间内刷新显示旧图像。
[(SDURLCache*)[NSURLCache sharedURLCache] removeCachedResponseForRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
[[Nimbus imageMemoryCache] removeObjectWithName:url];
[profilePic setPathToNetworkImage:url];
Which way is the right way to remove the cache? 删除缓存的正确方法是哪种?
I've added a new method to Nimbus' in-memory cache called removeAllObjectsWithPrefix:
. 我向Nimbus的内存缓存添加了一个名为removeAllObjectsWithPrefix:
的新方法。 You can use this method in the following way to forcefully expire images from the cache: 您可以通过以下方式使用此方法来强制使缓存中的图像过期:
[imageView.imageMemoryCache removeAllObjectsWithPrefix:imageUrl];
You will need to know the url in order to expire it from the cache. 您需要知道该URL才能使它从缓存中过期。
The reason why this method is necessary is because NINetworkImageView adds a suffix to the image cache key to differentiate between different sizes and content modes. 之所以需要这种方法,是因为NINetworkImageView在图像缓存键中添加了后缀,以区分不同的大小和内容模式。
https://github.com/jverkoey/nimbus/blob/master/src/networkimage/src/NINetworkImageView.m#L137 https://github.com/jverkoey/nimbus/blob/master/src/networkimage/src/NINetworkImageView.m#L137
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.