当您使用:
- (void)storeImage:(UIImage *)image forKey:(NSString *)key
图像也保存在磁盘缓存中。
实现类似于:
- (void)storeImage:(UIImage *)image forKey:(NSString *)key
{
[self storeImage:image imageData:nil forKey:key toDisk:YES];
}
因此,如果您需要从磁盘中检索图像,则可以使用以下方法:
- (void)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock;
默认磁盘缓存类型为SDImageCacheTypeNone
,因此如果您需要指定缓存类型,请使用SDImageCacheType
枚举。
enum SDImageCacheType
{
/**
* The image wasn't available the SDWebImage caches, but was downloaded from the web.
*/
SDImageCacheTypeNone = 0,
/**
* The image was obtained from the disk cache.
*/
SDImageCacheTypeDisk,
/**
* The image was obtained from the disk cache.
*/
SDImageCacheTypeMemory
};
希望,它会帮助你。