Skip to content

Commit

Permalink
Add NSCache countLimit property in attempts to get better control of …
Browse files Browse the repository at this point in the history
…cache eviction.
  • Loading branch information
rromanchuk committed May 11, 2015
1 parent 704c630 commit f72f4c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions SDWebImage/SDImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 8 additions & 0 deletions SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ - (NSUInteger)maxMemoryCost {
return self.memCache.totalCostLimit;
}

- (NSUInteger)maxMemoryCountLimit {
return self.memCache.countLimit;
}

- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit {
self.memCache.countLimit = maxCountLimit;
}

- (void)clearMemory {
[self.memCache removeAllObjects];
}
Expand Down

0 comments on commit f72f4c1

Please sign in to comment.