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
静态常量长整型。

转载:http://www.cnblogs.com/cbios/p/7426348.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容