简体   繁体   中英

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: . 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.

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.

https://github.com/jverkoey/nimbus/blob/master/src/networkimage/src/NINetworkImageView.m#L137

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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