Add NSCache countLimit property in attempts to get better control of cache eviction.
This commit is contained in:
parent
704c630567
commit
f72f4c183d
|
@ -47,6 +47,11 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot
|
||||||
*/
|
*/
|
||||||
@property (assign, nonatomic) NSUInteger maxMemoryCost;
|
@property (assign, nonatomic) NSUInteger maxMemoryCost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of objects the cache should hold.
|
||||||
|
*/
|
||||||
|
@property (assign, nonatomic) NSUInteger maxMemoryCountLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum length of time to keep an image in the cache, in seconds
|
* The maximum length of time to keep an image in the cache, in seconds
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -377,6 +377,14 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
return self.memCache.totalCostLimit;
|
return self.memCache.totalCostLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSUInteger)maxMemoryCountLimit {
|
||||||
|
return self.memCache.countLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit {
|
||||||
|
self.memCache.countLimit = maxCountLimit;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)clearMemory {
|
- (void)clearMemory {
|
||||||
[self.memCache removeAllObjects];
|
[self.memCache removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue