Merge pull request #556 from JoshuaGross/master

Allow setting a custom memory cost limit for the in-memory NSCache.
This commit is contained in:
Olivier Poitrey 2013-11-22 16:46:16 -08:00
commit 2043094ab5
2 changed files with 15 additions and 0 deletions

View File

@ -32,6 +32,11 @@ typedef enum SDImageCacheType SDImageCacheType;
*/
@interface SDImageCache : NSObject
/**
* The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory.
*/
@property (assign, nonatomic) NSUInteger maxMemoryCost;
/**
* The maximum length of time to keep an image in the cache, in seconds
*/

View File

@ -338,6 +338,16 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
}
}
- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost
{
self.memCache.totalCostLimit = maxMemoryCost;
}
- (NSUInteger)maxMemoryCost
{
return self.memCache.totalCostLimit;
}
- (void)clearMemory
{
[self.memCache removeAllObjects];