Merge branch 'master' of https://github.com/rs/SDWebImage into 5.x

* 'master' of https://github.com/rs/SDWebImage:
  Revert that SDImageCacheQueryMemoryOnly because it's misunderstanding. Use `imageFromMemoryCacheForKey` instead
This commit is contained in:
DreamPiggy 2018-01-26 23:50:17 +08:00
commit 2990737821
4 changed files with 4 additions and 9 deletions

View File

@ -27,18 +27,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);

View File

@ -415,7 +415,7 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
// 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);

View File

@ -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,

View File

@ -151,7 +151,6 @@
NSString *key = [self cacheKeyForURL:url];
SDImageCacheOptions cacheOptions = 0;
if (options & SDWebImageCacheMemoryOnly) cacheOptions |= SDImageCacheQueryMemoryOnly;
if (options & SDWebImageQueryDataWhenInMemory) cacheOptions |= SDImageCacheQueryDataWhenInMemory;
if (options & SDWebImageQueryDiskSync) cacheOptions |= SDImageCacheQueryDiskSync;