【问题标题】:How does Picasso's disk caching work?Picasso 的磁盘缓存是如何工作的?
【发布时间】:2016-03-16 13:18:47
【问题描述】:

我正在使用 Picasso 加载图像。我已启用调试标志,显示图像是从 RAM、磁盘还是网络加载。

从标志中我知道它默认使用 RAM 进行缓存。如果我使用 skipMemoryCache() 方法,它会自动使用磁盘缓存而不是 RAM。

所以,我的问题是: 1.缓存图像在磁盘(和RAM)中存在多长时间? 2.如果需要,如何手动清除这个缓存(磁盘和内存)?

【问题讨论】:

    标签: android caching picasso


    【解决方案1】:
    1.How long do the cached images exist in the disk(and RAM)?
    

    缓存的是LRU(最近最少使用)。默认情况下,Picasso 尝试将大约 15% 的可用堆分配给您的应用程序作为运行时缓存,大约 2% 用于磁盘缓存。当 RAM 缓存已满,并且您尝试向其中添加新项目时,最小的将从缓存中删除,以便为最新的项目腾出空间

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

    您导致库提供的invalidate() 方法之一

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-01
      • 2014-07-21
      • 2015-11-15
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 2013-09-07
      • 2015-05-16
      相关资源
      最近更新 更多