Merge pull request #1140 from rromanchuk/feature/add-count-limits

Add NSCache countLimit property
This commit is contained in:
Olivier Poitrey 2015-05-11 12:48:37 -07:00
commit 98989d9524
2 changed files with 13 additions and 0 deletions

View File

@ -47,6 +47,11 @@ typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger tot
*/
@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
*/

View File

@ -377,6 +377,14 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
return self.memCache.totalCostLimit;
}
- (NSUInteger)maxMemoryCountLimit {
return self.memCache.countLimit;
}
- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit {
self.memCache.countLimit = maxCountLimit;
}
- (void)clearMemory {
[self.memCache removeAllObjects];
}