fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Support removing / evicting images from disk cache

Open bjzhou opened this issue 11 years ago • 6 comments

The picture on the server changed, but fresco still load the old one, I tried the code Fresco.getImagePipeline().evictFromMemoryCache(uri);, but it not work. Does it only clear the memory cache? If so, how to clear the disk cache?

bjzhou avatar Apr 10 '15 01:04 bjzhou

We don't expose that functionality yet, but that shouldn't be hard to support.

plamenko avatar Apr 10 '15 13:04 plamenko

I also have this same issue, it would be great to have something to clear the local cache manually or set some expiration time.

danilobertelli avatar Apr 16 '15 18:04 danilobertelli

There is an expiration time for disk cache. If I remember correctly it is set to 60 days. There are other things on our priority list at the moment, but if one of you sends a pull request for adding evictFromDiskCache we will take a look.

plamenko avatar Apr 17 '15 00:04 plamenko

I will try to do something in my free time.. But from now, I can use: Uri uri = Uri.parse("http://frescolib.org/static/fresco-logo.png"); Fresco.getImagePipelineFactory().getMainDiskStorageCache().remove(new CacheKey(uri.toString())); Fresco.getImagePipelineFactory().getSmallImageDiskStorageCache().remove(new CacheKey(uri.toString()));

This remove from local cache.. I don't know the unexpected behavior that this will cause.

danilobertelli avatar Apr 17 '15 19:04 danilobertelli

@danilobertelli , yeah this should work. We should simplify the API though (like we have for removing from memory cache).

Also, one thing to watch out for is when using a custom CacheKeyFactory (unlikely, but possible). The default one does what you do, so if the default one is used, it hsould be fine. https://github.com/facebook/fresco/blob/847851a8de6d223c0a6634447bddee1252e01c64/imagepipeline/src/main/java/com/facebook/imagepipeline/cache/DefaultCacheKeyFactory.java

plamenko avatar Apr 18 '15 00:04 plamenko

Added in v0.6.0. See http://frescolib.org/docs/caching.html#evicting-from-cache

tyronen avatar Jul 20 '15 21:07 tyronen