Search code examples
androidcachingpicasso

How does Picasso's disk caching work?


I am using Picasso for loading images.I have enabled debug flags which show if the image is being loaded from RAM,disk or network.

From the flags i got to know that it is using the RAM by default for caching. If I use the skipMemoryCache() method it is automatically using disk caching instead of the RAM.

So, my questions are: 1.How long do the cached images exist in the disk(and RAM)? 2.How to manually clear this cache(both disk and RAM) if needed?


Solution

  • 1.How long do the cached images exist in the disk(and RAM)?
    

    the cached is a LRU (least recently used). By default Picasso try to allocate around 15% of the heap available for your app as runtime cache and around 2% for the disk cache. When the RAM cache is full, and you try to add a new item to it, the least is removed from the cache to make space for the newest

    2.How to manually clear this cache(both disk and RAM) if needed?
    

    you cause one of the invalidate() methods provided by the library