Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize PINMemoryCache remove objects when receive memory warning notification #251

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Add your own contributions to the next release on the line below this with your name.

- [performance] Optimize `PINMemoryCache` remove objects when receive memory warning notification. [#251](https://github.com/pinterest/PINCache/pull/251)

## 3.0.1 -- Beta 8
- [fix] Initing PINCache with TTL enabled should enable TTL on PINMemoryCache. [#246](https://github.com/pinterest/PINCache/pull/246)
- [performance] Return TTL cache objects without waiting for all metadata to be read. [#228](https://github.com/pinterest/PINCache/pull/228)
Expand Down
7 changes: 4 additions & 3 deletions Source/PINMemoryCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ + (PINMemoryCache *)sharedCache
#pragma mark - Private Methods -

- (void)didReceiveMemoryWarningNotification:(NSNotification *)notification {
if (self.removeAllObjectsOnMemoryWarning)
if (self.removeAllObjectsOnMemoryWarning) {
[self removeAllObjectsAsync:nil];

[self removeExpiredObjects];
} else {
[self removeExpiredObjects];
}

[self.operationQueue scheduleOperation:^{
[self lock];
Expand Down