zoukankan      html  css  js  c++  java
  • SDWebImage 清除磁盘缓存机制 iOS

    分析的版本

    pod 'SDWebImage', '~> 5.0.6'

    SDWebImage默认清除磁盘缓存的时长是7天。

    /**
     * The maximum length of time to keep an image in the disk cache, in seconds.
     * Setting this to a negative value means no expiring.
     * Setting this to zero means that all cached files would be removed when do expiration check.
     * Defaults to 1 week.
     */
    @property (assign, nonatomic) NSTimeInterval maxDiskAge;


    那么SDWebImage是如何进行操作的?
    进入SDImageCache的头文件会发现有这么一段代码

    - (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock {
        dispatch_async(self.ioQueue, ^{
            [self.diskCache removeExpiredData];
            if (completionBlock) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    completionBlock();
                });
            }
        });
    }

    调用的地方有两个(APP将要中断,进入后台之后)

    - (void)applicationWillTerminate:(NSNotification *)notification
    - (void)applicationDidEnterBackground:(NSNotification *)notification
  • 相关阅读:
    能直接调用析构函数,不能直接调用构造函数
    第二章、IP协议详解
    第一章、TCP协议详解
    STL
    容器
    7、jQuery选择器及绑定方法
    6、JQuery语法
    5、DOM 定时器 和 JQuery 选择器
    4、DOM之正则表达式
    3、JS函数与DOM事件
  • 原文地址:https://www.cnblogs.com/huangzs/p/13598383.html
Copyright © 2011-2022 走看看