Rename the cache protocol to `SDImageCache` protocol

This commit is contained in:
DreamPiggy 2018-04-18 19:16:45 +08:00
parent bee5425078
commit 734c6821d5
8 changed files with 92 additions and 95 deletions

View File

@ -508,18 +508,18 @@
32CF1C101FA496B000004BD1 /* SDWebImageCoderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 32CF1C061FA496B000004BD1 /* SDWebImageCoderHelper.m */; };
32CF1C111FA496B000004BD1 /* SDWebImageCoderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 32CF1C061FA496B000004BD1 /* SDWebImageCoderHelper.m */; };
32CF1C121FA496B000004BD1 /* SDWebImageCoderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 32CF1C061FA496B000004BD1 /* SDWebImageCoderHelper.m */; };
32D1221E2080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D1221F2080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122202080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122212080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122222080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122232080B2EB003685A3 /* SDWebImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDWebImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122242080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D122252080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D122262080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D122272080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D122282080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D122292080B2EB003685A3 /* SDWebImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDWebImageCache.m */; };
32D1221E2080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D1221F2080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122202080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122212080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122222080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122232080B2EB003685A3 /* SDImageCacheDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
32D122242080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D122252080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D122262080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D122272080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D122282080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D122292080B2EB003685A3 /* SDImageCacheDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */; };
32D1222A2080B2EB003685A3 /* SDImageCachesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221C2080B2EB003685A3 /* SDImageCachesManager.m */; };
32D1222B2080B2EB003685A3 /* SDImageCachesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221C2080B2EB003685A3 /* SDImageCachesManager.m */; };
32D1222C2080B2EB003685A3 /* SDImageCachesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 32D1221C2080B2EB003685A3 /* SDImageCachesManager.m */; };
@ -1596,8 +1596,8 @@
32C0FDE02013426C001B8F2D /* SDWebImageIndicator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageIndicator.m; sourceTree = "<group>"; };
32CF1C051FA496B000004BD1 /* SDWebImageCoderHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageCoderHelper.h; sourceTree = "<group>"; };
32CF1C061FA496B000004BD1 /* SDWebImageCoderHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCoderHelper.m; sourceTree = "<group>"; };
32D1221A2080B2EB003685A3 /* SDWebImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageCache.h; sourceTree = "<group>"; };
32D1221B2080B2EB003685A3 /* SDWebImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCache.m; sourceTree = "<group>"; };
32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDImageCacheDefine.h; sourceTree = "<group>"; };
32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDImageCacheDefine.m; sourceTree = "<group>"; };
32D1221C2080B2EB003685A3 /* SDImageCachesManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDImageCachesManager.m; sourceTree = "<group>"; };
32D1221D2080B2EB003685A3 /* SDImageCachesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDImageCachesManager.h; sourceTree = "<group>"; };
32F21B4F20788D8C0036B1D5 /* SDWebImageDownloaderRequestModifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDWebImageDownloaderRequestModifier.h; sourceTree = "<group>"; };
@ -2118,8 +2118,8 @@
328BB6C02082581100760D6C /* SDMemoryCache.m */,
328BB6BD2082581100760D6C /* SDDiskCache.h */,
328BB6BE2082581100760D6C /* SDDiskCache.m */,
32D1221A2080B2EB003685A3 /* SDWebImageCache.h */,
32D1221B2080B2EB003685A3 /* SDWebImageCache.m */,
32D1221A2080B2EB003685A3 /* SDImageCacheDefine.h */,
32D1221B2080B2EB003685A3 /* SDImageCacheDefine.m */,
32D1221D2080B2EB003685A3 /* SDImageCachesManager.h */,
32D1221C2080B2EB003685A3 /* SDImageCachesManager.m */,
);
@ -2342,7 +2342,7 @@
323F8B531F38EF770092B609 /* backward_references_enc.h in Headers */,
4317395A1CDFC8B70008FEB9 /* mux_types.h in Headers */,
431739561CDFC8B70008FEB9 /* demux.h in Headers */,
32D122212080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D122212080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
32B9B53A206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
328BB6AD2081FEE500760D6C /* SDWebImageCacheSerializer.h in Headers */,
80377C4A1F2F666300F89830 /* bit_writer_utils.h in Headers */,
@ -2440,7 +2440,7 @@
80377C1D1F2F666300F89830 /* huffman_encode_utils.h in Headers */,
321E60B11F38E90100405457 /* SDWebImageWebPCoder.h in Headers */,
80377E9A1F2F66D400F89830 /* common_dec.h in Headers */,
32D1221F2080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D1221F2080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
327054D5206CD8B3006EA328 /* SDWebImageAPNGCoder.h in Headers */,
328BB6AB2081FEE500760D6C /* SDWebImageCacheSerializer.h in Headers */,
32B9B538206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
@ -2609,7 +2609,7 @@
32F7C0732030114C00873181 /* SDWebImageTransformer.h in Headers */,
431BB6FA1D06D2C1006A3455 /* SDWebImageDownloader.h in Headers */,
3248476D201775F600AF9E5A /* SDAnimatedImageView.h in Headers */,
32D122222080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D122222080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
80377DF51F2F66A800F89830 /* common_sse2.h in Headers */,
323F8BDC1F38EF770092B609 /* vp8i_enc.h in Headers */,
80377ED21F2F66D500F89830 /* vp8i_dec.h in Headers */,
@ -2630,7 +2630,7 @@
32F7C0892030719600873181 /* UIImage+Transform.h in Headers */,
80377EDA1F2F66D500F89830 /* common_dec.h in Headers */,
80377EE61F2F66D500F89830 /* webpi_dec.h in Headers */,
32D122232080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D122232080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
32B9B53C206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
328BB6AF2081FEE500760D6C /* SDWebImageCacheSerializer.h in Headers */,
4397D2BA1D0DDD8C00BB2784 /* demux.h in Headers */,
@ -2729,7 +2729,7 @@
323F8B521F38EF770092B609 /* backward_references_enc.h in Headers */,
4317394F1CDFC8B70008FEB9 /* demux.h in Headers */,
43CE757D1CFE9427006C64D0 /* FLAnimatedImageView.h in Headers */,
32D122202080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D122202080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
32B9B539206ED4230026769D /* SDWebImageDownloaderConfig.h in Headers */,
328BB6AC2081FEE500760D6C /* SDWebImageCacheSerializer.h in Headers */,
80377C301F2F666300F89830 /* bit_writer_utils.h in Headers */,
@ -2901,7 +2901,7 @@
323F8B6E1F38EF770092B609 /* delta_palettization_enc.h in Headers */,
438096721CDFC08200DC626B /* MKAnnotationView+WebCache.h in Headers */,
43CE757C1CFE9427006C64D0 /* FLAnimatedImageView.h in Headers */,
32D1221E2080B2EB003685A3 /* SDWebImageCache.h in Headers */,
32D1221E2080B2EB003685A3 /* SDImageCacheDefine.h in Headers */,
80377E8A1F2F66D000F89830 /* common_dec.h in Headers */,
AB615303192DA24600A2D8E9 /* UIView+WebCacheOperation.h in Headers */,
323F8B501F38EF770092B609 /* backward_references_enc.h in Headers */,
@ -3261,7 +3261,7 @@
80377DB51F2F66A700F89830 /* cpu.c in Sources */,
80377EC51F2F66D500F89830 /* webp_dec.c in Sources */,
80377DD61F2F66A700F89830 /* lossless_neon.c in Sources */,
32D122272080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122272080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
00733A5C1BC4880000A5A117 /* UIButton+WebCache.m in Sources */,
80377EC01F2F66D500F89830 /* vp8_dec.c in Sources */,
80377C521F2F666300F89830 /* huffman_utils.c in Sources */,
@ -3345,7 +3345,7 @@
4314D1341D0E0E3B004B36C9 /* UIImage+WebP.m in Sources */,
80377D3D1F2F66A700F89830 /* filters_mips_dsp_r2.c in Sources */,
323F8B751F38EF770092B609 /* filter_enc.c in Sources */,
32D122252080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122252080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
80377D401F2F66A700F89830 /* filters_sse2.c in Sources */,
80377D1E1F2F66A700F89830 /* alpha_processing_mips_dsp_r2.c in Sources */,
80377D291F2F66A700F89830 /* cost_sse2.c in Sources */,
@ -3509,7 +3509,7 @@
323F8BE21F38EF770092B609 /* vp8l_enc.c in Sources */,
431BB6A31D06D2C1006A3455 /* UIImageView+WebCache.m in Sources */,
80377E0C1F2F66A800F89830 /* filters_mips_dsp_r2.c in Sources */,
32D122282080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122282080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
323F8B781F38EF770092B609 /* filter_enc.c in Sources */,
4369C2821D9807EC007E863A /* UIView+WebCache.m in Sources */,
80377E0F1F2F66A800F89830 /* filters_sse2.c in Sources */,
@ -3705,7 +3705,7 @@
80377E381F2F66A800F89830 /* argb_sse2.c in Sources */,
323F8B9B1F38EF770092B609 /* near_lossless_enc.c in Sources */,
32F21B5C20788D8C0036B1D5 /* SDWebImageDownloaderRequestModifier.m in Sources */,
32D122292080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122292080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
80377E3B1F2F66A800F89830 /* cost_mips_dsp_r2.c in Sources */,
4397D29B1D0DDD8C00BB2784 /* SDWebImageDownloader.m in Sources */,
80377E711F2F66A800F89830 /* upsampling.c in Sources */,
@ -3923,7 +3923,7 @@
80377D8C1F2F66A700F89830 /* lossless_enc_sse2.c in Sources */,
4A2CAE2C1AB4BB7500B6BC39 /* UIButton+WebCache.m in Sources */,
80377EB51F2F66D400F89830 /* webp_dec.c in Sources */,
32D122262080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122262080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
80377D701F2F66A700F89830 /* cpu.c in Sources */,
80377D911F2F66A700F89830 /* lossless_neon.c in Sources */,
80377EB01F2F66D400F89830 /* vp8_dec.c in Sources */,
@ -4091,7 +4091,7 @@
A18A6CC9172DC28500419892 /* UIImage+GIF.m in Sources */,
80377E951F2F66D000F89830 /* webp_dec.c in Sources */,
80377CE61F2F66A100F89830 /* cpu.c in Sources */,
32D122242080B2EB003685A3 /* SDWebImageCache.m in Sources */,
32D122242080B2EB003685A3 /* SDImageCacheDefine.m in Sources */,
80377D071F2F66A100F89830 /* lossless_neon.c in Sources */,
80377E901F2F66D000F89830 /* vp8_dec.c in Sources */,
80377C041F2F665300F89830 /* huffman_utils.c in Sources */,

View File

@ -10,7 +10,7 @@
#import "SDWebImageCompat.h"
#import "SDWebImageDefine.h"
#import "SDImageCacheConfig.h"
#import "SDWebImageCache.h"
#import "SDImageCacheDefine.h"
typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
/**
@ -46,14 +46,8 @@ typedef NS_OPTIONS(NSUInteger, SDImageCacheOptions) {
SDImageCachePreloadAllFrames = 1 << 6
};
typedef void(^SDImageCacheCheckCompletionBlock)(BOOL isInCache);
typedef void(^SDImageCacheCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize);
typedef NSString * _Nullable (^SDImageCacheAdditionalCachePathBlock)(NSString * _Nonnull key);
/**
* SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed
* SDImageCache maintains a memory cache and a disk cache. Disk cache write operations are performed
* asynchronous so it doesnt add unnecessary latency to the UI.
*/
@interface SDImageCache : NSObject
@ -332,6 +326,6 @@ typedef NSString * _Nullable (^SDImageCacheAdditionalCachePathBlock)(NSString *
/**
* SDImageCache is the built-in image cache implementation for web image manager. It adopts `SDWebImageCache` protocol to provide the function for web image manager to use for image loading process.
*/
@interface SDImageCache (SDWebImageCache) <SDWebImageCache>
@interface SDImageCache (SDWebImageCache) <SDImageCache>
@end

View File

@ -34,6 +34,9 @@ typedef NS_ENUM(NSInteger, SDImageCacheType) {
SDImageCacheTypeAll
};
typedef void(^SDImageCacheCheckCompletionBlock)(BOOL isInCache);
typedef void(^SDImageCacheCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize);
typedef NSString * _Nullable (^SDImageCacheAdditionalCachePathBlock)(NSString * _Nonnull key);
typedef void(^SDImageCacheQueryCompletionBlock)(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType);
typedef void(^SDImageCacheContainsCompletionBlock)(SDImageCacheType containsCacheType);
@ -54,7 +57,7 @@ FOUNDATION_EXPORT UIImage * _Nullable SDWebImageCacheDecodeImageData(NSData * _N
Though the best practice to custom image cache, is to write your own class which conform `SDMemoryCache` or `SDDiskCache` protocol for `SDImageCache` class (See more on `SDImageCacheConfig.memoryCacheClass & SDImageCacheConfig.diskCacheClass`).
However, if your own cache implementation contains more advanced feature beyond `SDImageCache` itself, you can consider to provide this instead. For example, you can even use a cache manager like `SDWebImageCachesManager` to register multiple caches.
*/
@protocol SDWebImageCache <NSObject>
@protocol SDImageCache <NSObject>
@required
/**

View File

@ -6,7 +6,7 @@
* file that was distributed with this source code.
*/
#import "SDWebImageCache.h"
#import "SDImageCacheDefine.h"
#import "SDWebImageCodersManager.h"
#import "SDWebImageCoderHelper.h"
#import "SDAnimatedImage.h"

View File

@ -7,7 +7,7 @@
*/
#import <Foundation/Foundation.h>
#import "SDWebImageCache.h"
#import "SDImageCacheDefine.h"
typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) {
SDImageCachesManagerOperationPolicySerial, // process all caches serially (from the highest priority to the lowest priority cache by order)
@ -16,7 +16,7 @@ typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) {
SDImageCachesManagerOperationPolicyLowestOnly // process the lowest priority cache only
};
@interface SDImageCachesManager : NSObject <SDWebImageCache>
@interface SDImageCachesManager : NSObject <SDImageCache>
/**
Returns the global shared caches manager instance.
@ -58,20 +58,20 @@ typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) {
/**
All caches in caches manager. The caches array is a priority queue, which means the later added cache will have the highest priority
*/
@property (atomic, copy, readwrite, nullable) NSArray<id<SDWebImageCache>> *caches;
@property (atomic, copy, readwrite, nullable) NSArray<id<SDImageCache>> *caches;
/**
Add a new cache to the end of caches array. Which has the highest priority.
@param cache cache
*/
- (void)addCache:(nonnull id<SDWebImageCache>)cache;
- (void)addCache:(nonnull id<SDImageCache>)cache;
/**
Remove a cache in the caches array.
@param cache cache
*/
- (void)removeCache:(nonnull id<SDWebImageCache>)cache;
- (void)removeCache:(nonnull id<SDImageCache>)cache;
@end

View File

@ -95,11 +95,11 @@
#pragma mark - Cache IO operations
- (void)addCache:(id<SDWebImageCache>)cache {
if (![cache conformsToProtocol:@protocol(SDWebImageCache)]) {
- (void)addCache:(id<SDImageCache>)cache {
if (![cache conformsToProtocol:@protocol(SDImageCache)]) {
return;
}
NSMutableArray<id<SDWebImageCache>> *mutableCaches = [self.caches mutableCopy];
NSMutableArray<id<SDImageCache>> *mutableCaches = [self.caches mutableCopy];
if (!mutableCaches) {
mutableCaches = [NSMutableArray array];
}
@ -107,11 +107,11 @@
self.caches = [mutableCaches copy];
}
- (void)removeCache:(id<SDWebImageCache>)cache {
if (![cache conformsToProtocol:@protocol(SDWebImageCache)]) {
- (void)removeCache:(id<SDImageCache>)cache {
if (![cache conformsToProtocol:@protocol(SDImageCache)]) {
return;
}
NSMutableArray<id<SDWebImageCache>> *mutableCaches = [self.caches mutableCopy];
NSMutableArray<id<SDImageCache>> *mutableCaches = [self.caches mutableCopy];
[mutableCaches removeObject:cache];
self.caches = [mutableCaches copy];
}
@ -122,7 +122,7 @@
if (!key) {
return nil;
}
NSArray<id<SDWebImageCache>> *caches = [self.caches copy];
NSArray<id<SDImageCache>> *caches = [self.caches copy];
NSUInteger count = caches.count;
if (count == 0) {
return nil;
@ -131,12 +131,12 @@
}
switch (self.queryOperationPolicy) {
case SDImageCachesManagerOperationPolicyHighestOnly: {
id<SDWebImageCache> cache = caches.lastObject;
id<SDImageCache> cache = caches.lastObject;
return [cache queryImageForKey:key options:options context:context completion:completionBlock];
}
break;
case SDImageCachesManagerOperationPolicyLowestOnly: {
id<SDWebImageCache> cache = caches.firstObject;
id<SDImageCache> cache = caches.firstObject;
return [cache queryImageForKey:key options:options context:context completion:completionBlock];
}
break;
@ -164,7 +164,7 @@
if (!key) {
return;
}
NSArray<id<SDWebImageCache>> *caches = [self.caches copy];
NSArray<id<SDImageCache>> *caches = [self.caches copy];
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -174,12 +174,12 @@
}
switch (self.storeOperationPolicy) {
case SDImageCachesManagerOperationPolicyHighestOnly: {
id<SDWebImageCache> cache = caches.lastObject;
id<SDImageCache> cache = caches.lastObject;
[cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock];
}
break;
case SDImageCachesManagerOperationPolicyLowestOnly: {
id<SDWebImageCache> cache = caches.firstObject;
id<SDImageCache> cache = caches.firstObject;
[cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:completionBlock];
}
break;
@ -202,7 +202,7 @@
if (!key) {
return;
}
NSArray<id<SDWebImageCache>> *caches = [self.caches copy];
NSArray<id<SDImageCache>> *caches = [self.caches copy];
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -212,12 +212,12 @@
}
switch (self.removeOperationPolicy) {
case SDImageCachesManagerOperationPolicyHighestOnly: {
id<SDWebImageCache> cache = caches.lastObject;
id<SDImageCache> cache = caches.lastObject;
[cache removeImageForKey:key cacheType:cacheType completion:completionBlock];
}
break;
case SDImageCachesManagerOperationPolicyLowestOnly: {
id<SDWebImageCache> cache = caches.firstObject;
id<SDImageCache> cache = caches.firstObject;
[cache removeImageForKey:key cacheType:cacheType completion:completionBlock];
}
break;
@ -240,7 +240,7 @@
if (!key) {
return;
}
NSArray<id<SDWebImageCache>> *caches = [self.caches copy];
NSArray<id<SDImageCache>> *caches = [self.caches copy];
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -250,12 +250,12 @@
}
switch (self.clearOperationPolicy) {
case SDImageCachesManagerOperationPolicyHighestOnly: {
id<SDWebImageCache> cache = caches.lastObject;
id<SDImageCache> cache = caches.lastObject;
[cache containsImageForKey:key cacheType:cacheType completion:completionBlock];
}
break;
case SDImageCachesManagerOperationPolicyLowestOnly: {
id<SDWebImageCache> cache = caches.firstObject;
id<SDImageCache> cache = caches.firstObject;
[cache containsImageForKey:key cacheType:cacheType completion:completionBlock];
}
break;
@ -277,7 +277,7 @@
}
- (void)clearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock {
NSArray<id<SDWebImageCache>> *caches = [self.caches copy];
NSArray<id<SDImageCache>> *caches = [self.caches copy];
NSUInteger count = caches.count;
if (count == 0) {
return;
@ -287,12 +287,12 @@
}
switch (self.clearOperationPolicy) {
case SDImageCachesManagerOperationPolicyHighestOnly: {
id<SDWebImageCache> cache = caches.lastObject;
id<SDImageCache> cache = caches.lastObject;
[cache clearWithCacheType:cacheType completion:completionBlock];
}
break;
case SDImageCachesManagerOperationPolicyLowestOnly: {
id<SDWebImageCache> cache = caches.firstObject;
id<SDImageCache> cache = caches.firstObject;
[cache clearWithCacheType:cacheType completion:completionBlock];
}
break;
@ -313,10 +313,10 @@
#pragma mark - Concurrent Operation
- (void)concurrentQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)concurrentQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
for (id<SDWebImageCache> cache in enumerator) {
for (id<SDImageCache> cache in enumerator) {
[cache queryImageForKey:key options:options context:context completion:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
if (operation.isCancelled) {
// Cancelled
@ -346,10 +346,10 @@
}
}
- (void)concurrentStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)concurrentStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
for (id<SDWebImageCache> cache in enumerator) {
for (id<SDImageCache> cache in enumerator) {
[cache storeImage:image imageData:imageData forKey:key cacheType:cacheType completion:^{
if (operation.isCancelled) {
// Cancelled
@ -371,10 +371,10 @@
}
}
- (void)concurrentRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)concurrentRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
for (id<SDWebImageCache> cache in enumerator) {
for (id<SDImageCache> cache in enumerator) {
[cache removeImageForKey:key cacheType:cacheType completion:^{
if (operation.isCancelled) {
// Cancelled
@ -396,10 +396,10 @@
}
}
- (void)concurrentContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)concurrentContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
for (id<SDWebImageCache> cache in enumerator) {
for (id<SDImageCache> cache in enumerator) {
[cache containsImageForKey:key cacheType:cacheType completion:^(SDImageCacheType containsCacheType) {
if (operation.isCancelled) {
// Cancelled
@ -429,10 +429,10 @@
}
}
- (void)concurrentClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)concurrentClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
for (id<SDWebImageCache> cache in enumerator) {
for (id<SDImageCache> cache in enumerator) {
[cache clearWithCacheType:cacheType completion:^{
if (operation.isCancelled) {
// Cancelled
@ -456,10 +456,10 @@
#pragma mark - Serial Operation
- (void)serialQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)serialQueryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(SDWebImageContext *)context completion:(SDImageCacheQueryCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
id<SDWebImageCache> cache = enumerator.nextObject;
id<SDImageCache> cache = enumerator.nextObject;
if (!cache) {
// Complete
[operation done];
@ -492,9 +492,9 @@
}];
}
- (void)serialStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator {
- (void)serialStoreImage:(UIImage *)image imageData:(NSData *)imageData forKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator {
NSParameterAssert(enumerator);
id<SDWebImageCache> cache = enumerator.nextObject;
id<SDImageCache> cache = enumerator.nextObject;
if (!cache) {
// Complete
if (completionBlock) {
@ -509,9 +509,9 @@
}];
}
- (void)serialRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator {
- (void)serialRemoveImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator {
NSParameterAssert(enumerator);
id<SDWebImageCache> cache = enumerator.nextObject;
id<SDImageCache> cache = enumerator.nextObject;
if (!cache) {
// Complete
if (completionBlock) {
@ -526,10 +526,10 @@
}];
}
- (void)serialContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
- (void)serialContainsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(SDImageCacheContainsCompletionBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator operation:(SDImageCachesManagerOperation *)operation {
NSParameterAssert(enumerator);
NSParameterAssert(operation);
id<SDWebImageCache> cache = enumerator.nextObject;
id<SDImageCache> cache = enumerator.nextObject;
if (!cache) {
// Complete
[operation done];
@ -562,9 +562,9 @@
}];
}
- (void)serialClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDWebImageCache>> *)enumerator {
- (void)serialClearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock enumerator:(NSEnumerator<id<SDImageCache>> *)enumerator {
NSParameterAssert(enumerator);
id<SDWebImageCache> cache = enumerator.nextObject;
id<SDImageCache> cache = enumerator.nextObject;
if (!cache) {
// Complete
if (completionBlock) {

View File

@ -8,7 +8,7 @@
#import "SDWebImageCompat.h"
#import "SDWebImageOperation.h"
#import "SDWebImageCache.h"
#import "SDImageCacheDefine.h"
#import "SDWebImageDownloader.h"
#import "SDWebImageTransformer.h"
#import "SDWebImageCacheKeyFilter.h"
@ -99,7 +99,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
/**
* The image cache used by manager to query image cache.
*/
@property (strong, nonatomic, readonly, nonnull) id<SDWebImageCache> imageCache;
@property (strong, nonatomic, readonly, nonnull) id<SDImageCache> imageCache;
/**
* The image downloader used by manager to download image.
@ -158,7 +158,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
The default image cache when the manager which is created with no arguments. Such as shared manager or init.
Defaults to nil. Means using `SDImageCache.sharedImageCache`
*/
@property (nonatomic, class, nullable) id<SDWebImageCache> defaultImageCache;
@property (nonatomic, class, nullable) id<SDImageCache> defaultImageCache;
/**
The default image downloader for manager which is created with no arguments. Such as shared manager or init.
@ -175,7 +175,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
* Allows to specify instance of cache and image downloader used with image manager.
* @return new instance of `SDWebImageManager` with specified cache and downloader.
*/
- (nonnull instancetype)initWithCache:(nonnull id<SDWebImageCache>)cache downloader:(nonnull SDWebImageDownloader *)downloader NS_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithCache:(nonnull id<SDImageCache>)cache downloader:(nonnull SDWebImageDownloader *)downloader NS_DESIGNATED_INITIALIZER;
/**
* Downloads the image at the given URL if not present in cache or return the cached version otherwise.

View File

@ -13,7 +13,7 @@
#import "SDAnimatedImage.h"
#import "SDWebImageError.h"
static id<SDWebImageCache> _defaultImageCache;
static id<SDImageCache> _defaultImageCache;
static SDWebImageDownloader *_defaultImageDownloader;
@interface SDWebImageCombinedOperation ()
@ -36,12 +36,12 @@ static SDWebImageDownloader *_defaultImageDownloader;
@implementation SDWebImageManager
+ (id<SDWebImageCache>)defaultImageCache {
+ (id<SDImageCache>)defaultImageCache {
return _defaultImageCache;
}
+ (void)setDefaultImageCache:(id<SDWebImageCache>)defaultImageCache {
if (defaultImageCache && ![defaultImageCache conformsToProtocol:@protocol(SDWebImageCache)]) {
+ (void)setDefaultImageCache:(id<SDImageCache>)defaultImageCache {
if (defaultImageCache && ![defaultImageCache conformsToProtocol:@protocol(SDImageCache)]) {
return;
}
_defaultImageCache = defaultImageCache;
@ -68,7 +68,7 @@ static SDWebImageDownloader *_defaultImageDownloader;
}
- (nonnull instancetype)init {
id<SDWebImageCache> cache = [[self class] defaultImageCache];
id<SDImageCache> cache = [[self class] defaultImageCache];
if (!cache) {
cache = [SDImageCache sharedImageCache];
}
@ -79,7 +79,7 @@ static SDWebImageDownloader *_defaultImageDownloader;
return [self initWithCache:cache downloader:downloader];
}
- (nonnull instancetype)initWithCache:(nonnull id<SDWebImageCache>)cache downloader:(nonnull SDWebImageDownloader *)downloader {
- (nonnull instancetype)initWithCache:(nonnull id<SDImageCache>)cache downloader:(nonnull SDWebImageDownloader *)downloader {
if ((self = [super init])) {
_imageCache = cache;
_imageDownloader = downloader;