1

I am migrating android image caching library from picasso to fresco. I want to know if there is any way to invalidate image already catched as I am adding feature to replace existing image there is way to do so in picasso like

Picasso.with(context).invalidate(URI);

This line remove the cached image and use new one using the url provided which is same like,

http://example.com/image_path

In fresco I have tried using

Fresco.getImagePipeline().evictFromMemoryCache(uri);

This is removing image from view but adding same old cached image again and not getting new one from network as it is working in picasso.


Please refer question Invalidate cache in Picasso The accepted answer doing great in case of picasso.

Community
  • 1
  • 1
Umesh Aawte
  • 4,358
  • 6
  • 38
  • 50

2 Answers2

3
Fresco.getImagePipeline().evictFromMemoryCache(uri);

Above code line remove the image from the catche but image remains there in the disk and render same if called. We need to remove same image from disk as well. Bellow two lines remove the the image from disc cache also we need to remove the small that is thumbnail image if saved from disk cache.

Fresco.getImagePipelineFactory().getMainDiskStorageCache().remove(new SimpleCacheKey(uri.toString()));
Fresco.getImagePipelineFactory().getSmallImageDiskStorageCache().remove(new SimpleCacheKey(uri.toString()));

Note: if you are using custom cache key you need to change it that way.

Umesh Aawte
  • 4,358
  • 6
  • 38
  • 50
1

Try this

public static void clearCache(){
            //
            ImagePipeline imagePipeline = com.facebook.drawee.backends.pipeline.Fresco.getImagePipeline();
            imagePipeline.clearMemoryCaches();
            imagePipeline.clearDiskCaches();
            // combines above two lines
            imagePipeline.clearCaches();
        }