SDWebImage源码解读(二)SDImageCacheConfig

缓存配置对象,存储缓存配置信息

.h

@property (assign, nonatomic) BOOL shouldDecompressImages;

这个属性设置为yes,可以改善性能,但是会消耗大量内存。当你内存吃紧crash的时候,设置为no。默认是yes。

@property (assign, nonatomic) BOOL shouldDisableiCloud;

设置为yes,不使用iCloud云备份,默认为yes

@property (assign, nonatomic) BOOL shouldCacheImagesInMemory;

 设置为yes,在内存中缓存图片。默认为yes

@property (assign, nonatomic) NSInteger maxCacheAge;

缓存最长的保存时间,单位是秒,默认是一周

@property (assign, nonatomic) NSUInteger maxCacheSize;

最大缓存,单位是字节

.m

- (instancetype)init {
    if (self = [super init]) {
        _shouldDecompressImages = YES;
        _shouldDisableiCloud = YES;
        _shouldCacheImagesInMemory = YES;
        _maxCacheAge = kDefaultCacheMaxCacheAge;
        _maxCacheSize = 0;
    }
    return self;
}

初始化设置

static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week

静态常量长整型。

posted @ 2017-08-25 08:50  高山流水觅知音  阅读(279)  评论(0编辑  收藏  举报