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
  • 相关阅读:
    HDU 5495:LCS
    关于使用了cudaMallocHost之后发生 segment fault的原因
    关于grub 损坏的问题
    LightOJ
    LightOJ
    poj3268--Silver Cow Party (最短路+技巧)
    hdoj1443--Joseph (约瑟夫环)
    poj2549--Sumsets (sum)
    UVA11080
    hdoj1548--A strange lift(bfs.)
  • 原文地址:https://www.cnblogs.com/huangzs/p/13598383.html
Copyright © 2011-2022 走看看