Merge pull request #556 from JoshuaGross/master
Allow setting a custom memory cost limit for the in-memory NSCache.
This commit is contained in:
commit
2043094ab5
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue