BU_SDImageCachesManager.h
2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* This file is part of the SDWebImage package.
* (c) Olivier Poitrey <rs@dailymotion.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <Foundation/Foundation.h>
#import "BU_SDImageCacheDefine.h"
/// Policy for cache operation
typedef NS_ENUM(NSUInteger, SDImageCachesManagerOperationPolicy) {
SDImageCachesManagerOperationPolicySerial, // process all caches serially (from the highest priority to the lowest priority cache by order)
SDImageCachesManagerOperationPolicyConcurrent, // process all caches concurrently
SDImageCachesManagerOperationPolicyHighestOnly, // process the highest priority cache only
SDImageCachesManagerOperationPolicyLowestOnly // process the lowest priority cache only
};
/**
A caches manager to manage multiple caches.
*/
@interface BU_SDImageCachesManager : NSObject <BU_SDImageCache>
/**
Returns the global shared caches manager instance. By default we will set [`SDImageCache.sharedImageCache`] into the caches array.
*/
@property (nonatomic, class, readonly, nonnull) BU_SDImageCachesManager *sharedManager;
// These are op policy for cache manager.
/**
Operation policy for query op.
Defaults to `Serial`, means query all caches serially (one completion called then next begin) until one cache query success (`image` != nil).
*/
@property (nonatomic, assign) SDImageCachesManagerOperationPolicy queryOperationPolicy;
/**
Operation policy for store op.
Defaults to `HighestOnly`, means store to the highest priority cache only.
*/
@property (nonatomic, assign) SDImageCachesManagerOperationPolicy storeOperationPolicy;
/**
Operation policy for remove op.
Defaults to `Concurrent`, means remove all caches concurrently.
*/
@property (nonatomic, assign) SDImageCachesManagerOperationPolicy removeOperationPolicy;
/**
Operation policy for contains op.
Defaults to `Serial`, means check all caches serially (one completion called then next begin) until one cache check success (`containsCacheType` != None).
*/
@property (nonatomic, assign) SDImageCachesManagerOperationPolicy containsOperationPolicy;
/**
Operation policy for clear op.
Defaults to `Concurrent`, means clear all caches concurrently.
*/
@property (nonatomic, assign) SDImageCachesManagerOperationPolicy clearOperationPolicy;
/**
All caches in caches manager. The caches array is a priority queue, which means the later added cache will have the highest priority
*/
@property (nonatomic, copy, nullable) NSArray<id<BU_SDImageCache>> *caches;
/**
Add a new cache to the end of caches array. Which has the highest priority.
@param cache cache
*/
- (void)addCache:(nonnull id<BU_SDImageCache>)cache;
/**
Remove a cache in the caches array.
@param cache cache
*/
- (void)removeCache:(nonnull id<BU_SDImageCache>)cache;
@end