Skip to content

Commit

Permalink
Revert that SDImageCacheQueryMemoryOnly because it's misunderstanding…
Browse files Browse the repository at this point in the history
…. Use `imageFromMemoryCacheForKey` instead
  • Loading branch information
dreampiggy committed Jan 26, 2018
1 parent 5308754 commit 1749666
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
8 changes: 2 additions & 6 deletions SDWebImage/SDImageCache.h
Expand Up @@ -26,18 +26,14 @@ typedef NS_ENUM(NSInteger, SDImageCacheType) {
};

typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
/**
* By default, we will query disk cache if the memory cache missed. This mask can force to query memory cache only without disk data.
*/
SDImageCacheQueryMemoryOnly = 1 << 0,
/**
* 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.
*/
SDImageCacheQueryDataWhenInMemory = 1 << 1,
SDImageCacheQueryDataWhenInMemory = 1 << 0,
/**
* By default, we query the memory cache synchronously, disk cache asynchronously. This mask can force to query disk cache synchronously.
*/
SDImageCacheQueryDiskSync = 1 << 2
SDImageCacheQueryDiskSync = 1 << 1
};

typedef void(^SDCacheQueryCompletedBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
Expand Down
2 changes: 1 addition & 1 deletion SDWebImage/SDImageCache.m
Expand Up @@ -377,7 +377,7 @@ - (nullable NSOperation *)queryCacheOperationForKey:(nullable NSString *)key opt

// First check the in-memory cache...
UIImage *image = [self imageFromMemoryCacheForKey:key];
BOOL shouldQueryMemoryOnly = (options & SDImageCacheQueryMemoryOnly) || (image && !(options & SDImageCacheQueryDataWhenInMemory));
BOOL shouldQueryMemoryOnly = (image && !(options & SDImageCacheQueryDataWhenInMemory));
if (shouldQueryMemoryOnly) {
if (doneBlock) {
doneBlock(image, nil, SDImageCacheTypeMemory);
Expand Down
2 changes: 1 addition & 1 deletion SDWebImage/SDWebImageManager.h
Expand Up @@ -25,7 +25,7 @@ typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
SDWebImageLowPriority = 1 << 1,

/**
* This flag disables on-disk caching, including cache query and cache storing
* This flag disables on-disk caching after the download finished, only cache in memory
*/
SDWebImageCacheMemoryOnly = 1 << 2,

Expand Down
1 change: 0 additions & 1 deletion SDWebImage/SDWebImageManager.m
Expand Up @@ -146,7 +146,6 @@ - (void)diskImageExistsForURL:(nullable NSURL *)url
NSString *key = [self cacheKeyForURL:url];

SDImageCacheOptions cacheOptions = 0;
if (options & SDWebImageCacheMemoryOnly) cacheOptions |= SDImageCacheQueryMemoryOnly;
if (options & SDWebImageQueryDataWhenInMemory) cacheOptions |= SDImageCacheQueryDataWhenInMemory;
if (options & SDWebImageQueryDiskSync) cacheOptions |= SDImageCacheQueryDiskSync;

Expand Down

0 comments on commit 1749666

Please sign in to comment.