From 7dc9b30fa775e082330a04c7d880f8eddbd4007d Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Sun, 1 Oct 2017 15:33:34 -0700 Subject: [PATCH] Set some sane limits on the disk cache for people who forget. (#201) * Set some sane limits on the disk cache for people who forget. * Add CHANGELOG entry * let's go with 50 instead --- CHANGELOG.md | 1 + Source/PINDiskCache.m | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7cca1dd..cec87e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- [fix] Add some sane limits to the disk cache: [#201]https://github.com/pinterest/PINCache/pull/201 ## 3.0.1 -- Beta 5 - [fix] Respect small byteLimit settings by checking object size in setObject: [#198](https://github.com/pinterest/PINCache/pull/198) diff --git a/Source/PINDiskCache.m b/Source/PINDiskCache.m index 5070ff7f..bf449db3 100644 --- a/Source/PINDiskCache.m +++ b/Source/PINDiskCache.m @@ -150,8 +150,11 @@ - (instancetype)initWithName:(NSString *)name _didRemoveAllObjectsBlock = nil; _byteCount = 0; - _byteLimit = 0; - _ageLimit = 0.0; + + // 50 MB by default + _byteLimit = 50 * 1024 * 1024; + // 30 days by default + _ageLimit = 60 * 60 * 24 * 30; #if TARGET_OS_IPHONE _writingProtectionOption = NSDataWritingFileProtectionNone;