Update the cache options name to make it more clear
This commit is contained in:
parent
44aa6d513f
commit
df1bb98ad6
|
@ -46,8 +46,8 @@
|
|||
options:(SDWebImageOptions)options
|
||||
progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
|
||||
completed:(nullable SDExternalCompletionBlock)completedBlock {
|
||||
options |= SDWebImageQueryDiskDataWhenInMemory;
|
||||
options |= SDWebImageQueryDiskDataSync;
|
||||
options |= SDWebImageQueryDataWhenInMemory;
|
||||
options |= SDWebImageQueryDiskSync;
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
__weak typeof(self)weakSelf = self;
|
||||
[self sd_internalSetImageWithURL:url
|
||||
|
|
|
@ -27,13 +27,13 @@ typedef NS_ENUM(NSInteger, SDImageCacheType) {
|
|||
|
||||
typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
|
||||
/**
|
||||
* By default, we do not query disk cache when the image is cached in memory. This mask can force query disk data at the same time.
|
||||
* By default, we do not query disk data when the image is cached in memory. This mask can force to query disk data at the same time.
|
||||
*/
|
||||
SDImageCacheQueryDiskDataWhenInMemory = 1 << 0,
|
||||
SDImageCacheQueryDataWhenInMemory = 1 << 0,
|
||||
/**
|
||||
* By default, we query the memory cache synchonized, disk cache asynchronized. This mask can force to query disk cache synchonized.
|
||||
* By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously.
|
||||
*/
|
||||
SDImageCacheQueryDiskDataSync = 1 << 1
|
||||
SDImageCacheQueryDiskSync = 1 << 1
|
||||
};
|
||||
|
||||
typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
|
||||
|
|
|
@ -356,7 +356,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
|||
|
||||
// First check the in-memory cache...
|
||||
UIImage *image = [self imageFromMemoryCacheForKey:key];
|
||||
if (image && !(options & SDImageCacheQueryDiskDataWhenInMemory)) {
|
||||
if (image && !(options & SDImageCacheQueryDataWhenInMemory)) {
|
||||
if (doneBlock) {
|
||||
doneBlock(image, nil, SDImageCacheTypeMemory);
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
|||
}
|
||||
|
||||
if (doneBlock) {
|
||||
if (options & SDImageCacheQueryDiskDataSync) {
|
||||
if (options & SDImageCacheQueryDiskSync) {
|
||||
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
@ -394,7 +394,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
|||
}
|
||||
};
|
||||
|
||||
if (options & SDImageCacheQueryDiskDataSync) {
|
||||
if (options & SDImageCacheQueryDiskSync) {
|
||||
queryDiskBlock();
|
||||
} else {
|
||||
dispatch_async(self.ioQueue, queryDiskBlock);
|
||||
|
|
|
@ -97,16 +97,16 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
|
|||
SDWebImageScaleDownLargeImages = 1 << 12,
|
||||
|
||||
/**
|
||||
* By default, we do not query disk cache when the image is cached in memory. This mask can force query disk data at the same time.
|
||||
* This options is recommend to be used with `SDWebImageQueryDiskDataSync` to ensure the image is loaded in the same runloop.
|
||||
* By default, we do not query disk data when the image is cached in memory. This mask can force to query disk data at the same time.
|
||||
* This options is recommend to be used with `SDWebImageQueryDiskSync` to ensure the image is loaded in the same runloop.
|
||||
*/
|
||||
SDWebImageQueryDiskDataWhenInMemory = 1 << 13,
|
||||
SDWebImageQueryDataWhenInMemory = 1 << 13,
|
||||
|
||||
/**
|
||||
* By default, we query the memory cache synchonized, disk cache asynchronized. This mask can force to query disk cache synchonized to ensure that image is loaded in the same runloop.
|
||||
* By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously to ensure that image is loaded in the same runloop.
|
||||
* This can avoid flashing during cell reuse if you disable memory cache or in some other cases.
|
||||
*/
|
||||
SDWebImageQueryDiskDataSync = 1 << 14
|
||||
SDWebImageQueryDiskSync = 1 << 14
|
||||
};
|
||||
|
||||
typedef void(^SDExternalCompletionBlock)(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL);
|
||||
|
|
|
@ -145,8 +145,8 @@
|
|||
NSString *key = [self cacheKeyForURL:url];
|
||||
|
||||
SDImageCacheOptions cacheOptions = 0;
|
||||
if (options & SDWebImageQueryDiskDataWhenInMemory) cacheOptions |= SDImageCacheQueryDiskDataWhenInMemory;
|
||||
if (options & SDWebImageQueryDiskDataSync) cacheOptions |= SDImageCacheQueryDiskDataSync;
|
||||
if (options & SDWebImageQueryDataWhenInMemory) cacheOptions |= SDImageCacheQueryDataWhenInMemory;
|
||||
if (options & SDWebImageQueryDiskSync) cacheOptions |= SDImageCacheQueryDiskSync;
|
||||
|
||||
operation.cacheOperation = [self.imageCache queryCacheOperationForKey:key options:cacheOptions done:^(UIImage *cachedImage, NSData *cachedData, SDImageCacheType cacheType) {
|
||||
if (operation.isCancelled) {
|
||||
|
|
Loading…
Reference in New Issue