【问题标题】:How I can implement two caching strategy in UIL我如何在 UIL 中实现两种缓存策略
【发布时间】:2014-05-13 10:26:02
【问题描述】:

如何在一个应用程序中实施两种缓存策略。例如,来自一个应用程序部分的图像应该在一个文件夹中兑现,并具有最大内存/时间限制等。来自另一个部分的图像应该有另一个文件夹等。这些策略不应相互依赖。

【问题讨论】:

    标签: java android caching universal-image-loader


    【解决方案1】:

    ImageLoader 是单例,但它提供了受保护的构造函数,因此您可以扩展 ImageLoader 并创建第二个单例:

    public class ImageLoader2 extends ImageLoader {
    
        private volatile static ImageLoader instance;
    
        /** Returns singleton class instance */
        public static ImageLoader getInstance() {
            if (instance == null) {
                synchronized (ImageLoader2.class) {
                    if (instance == null) {
                        instance = new ImageLoader2();
                    }
                }
            }
            return instance;
        }
    }
    

    并将其与其他配置一起使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-16
      • 2014-10-05
      • 2021-10-10
      • 1970-01-01
      • 2011-11-23
      • 2010-10-06
      • 1970-01-01
      • 2012-09-05
      相关资源
      最近更新 更多