diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e16d84..bd84ce7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file. SPTPersistentCache adheres to [Semantic Versioning](http://semver.org/).
--
+## [1.1.2](https://github.com/spotify/SPTPersistentCache/releases/tag/1.1.2)
+
+### Added
+* SPTPersistentCacheOptions property allowing users to opt out of system backup.
+
## [1.1.1](https://github.com/spotify/SPTPersistentCache/releases/tag/1.1.1)
_Released on 2017-08-15._
diff --git a/README.md b/README.md
index 2a52bd5..74bca61 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ $ gem install cocoapods
```
Then simply add `SPTPersistentCache` to your `Podfile`.
```
-pod 'SPTPersistentCache', '~> 1.1.1'
+pod 'SPTPersistentCache', '~> 1.1.2'
```
Lastly let CocoaPods do its thing by running:
```shell
@@ -48,7 +48,7 @@ $ brew install carthage
```
You will also need to add `SPTPersistentCache` to your `Cartfile`:
```
-github "spotify/SPTPersistentCache" ~> 1.1.1
+github "spotify/SPTPersistentCache" ~> 1.1.2
```
After that is all said and done, let Carthage pull in SPTPersistentCache like so:
```shell
@@ -62,7 +62,7 @@ For an example of this framework's usage, see the demo application `SPTPersisten
### Creating the SPTPersistentCache
It is best to use different caches for different types of data you want to store, and not just one big cache for your entire application. However, only create one `SPTPersistentCache` instance for each cache, otherwise you might encounter anomalies when the two different caches end up writing to the same file.
```objc
-NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject stringByAppendingString:@"com.spotify.demo.image.cache"];
+NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:@"com.spotify.demo.image.cache"];
SPTPersistentCacheOptions *options = [SPTPersistentCacheOptions new];
options.cachePath = cachePath;
diff --git a/SPTPersistentCache.podspec b/SPTPersistentCache.podspec
index b5425e1..4197495 100644
--- a/SPTPersistentCache.podspec
+++ b/SPTPersistentCache.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPTPersistentCache"
- s.version = "1.1.1"
+ s.version = "1.1.2"
s.summary = "SPTPersistentCache is a fast, binary, LRU cache used in the Spotify iOS app"
s.description = <<-DESC
diff --git a/SPTPersistentCacheDemo/SPTPersistentCacheDemo/MasterViewController.m b/SPTPersistentCacheDemo/SPTPersistentCacheDemo/MasterViewController.m
index 9fb9513..f4b15bf 100644
--- a/SPTPersistentCacheDemo/SPTPersistentCacheDemo/MasterViewController.m
+++ b/SPTPersistentCacheDemo/SPTPersistentCacheDemo/MasterViewController.m
@@ -42,7 +42,7 @@ - (void)viewDidLoad
NSString *cacheIdentifier = @"com.spotify.demo.image.cache";
NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
NSUserDomainMask,
- YES).firstObject stringByAppendingString:cacheIdentifier];
+ YES).firstObject stringByAppendingPathComponent:cacheIdentifier];
SPTPersistentCacheOptions *options = [SPTPersistentCacheOptions new];
options.cachePath = cachePath;
diff --git a/SPTPersistentCacheFramework/Info.plist b/SPTPersistentCacheFramework/Info.plist
index 205d5f6..7e868aa 100644
--- a/SPTPersistentCacheFramework/Info.plist
+++ b/SPTPersistentCacheFramework/Info.plist
@@ -19,9 +19,9 @@
CFBundleSignature
????
CFBundleVersion
- 1.1.1
+ 1.1.2
NSHumanReadableCopyright
- Copyright © 2019 Spotify. All rights reserved.
+ Copyright © 2020 Spotify. All rights reserved.
NSPrincipalClass
diff --git a/Sources/SPTPersistentCacheFileManager.m b/Sources/SPTPersistentCacheFileManager.m
index 79c55fd..8344e97 100644
--- a/Sources/SPTPersistentCacheFileManager.m
+++ b/Sources/SPTPersistentCacheFileManager.m
@@ -60,7 +60,16 @@ - (BOOL)createCacheDirectory
return NO;
}
}
-
+
+ NSError *error = nil;
+ [[NSURL fileURLWithPath:self.options.cachePath] setResourceValue:@(self.options.shouldExcludeFromBackup) forKey:NSURLIsExcludedFromBackupKey error:&error];
+
+ if (error) {
+ SPTPersistentCacheSafeDebugCallback([NSString stringWithFormat:
+ @"PersistentDataCache: Resource value: %@ could not be set for key 'NSURLIsExcludedFromBackupKey' because: %@",
+ @(self.options.shouldExcludeFromBackup), error], self.debugOutput);
+ }
+
return YES;
}
diff --git a/Sources/SPTPersistentCacheOptions.m b/Sources/SPTPersistentCacheOptions.m
index 36f2234..9bc47c7 100644
--- a/Sources/SPTPersistentCacheOptions.m
+++ b/Sources/SPTPersistentCacheOptions.m
@@ -51,6 +51,7 @@ - (instancetype)init
_cachePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"/com.spotify.temppersistent.image.cache"];
_cacheIdentifier = @"persistent.cache";
_useDirectorySeparation = YES;
+ _shouldExcludeFromBackup = NO;
_garbageCollectionInterval = SPTPersistentCacheDefaultGCIntervalSec;
_defaultExpirationPeriod = SPTPersistentCacheDefaultExpirationTimeSec;
@@ -113,6 +114,7 @@ - (id)copyWithZone:(NSZone *)zone
copy.cacheIdentifier = self.cacheIdentifier;
copy.cachePath = self.cachePath;
copy.useDirectorySeparation = self.useDirectorySeparation;
+ copy.shouldExcludeFromBackup = self.shouldExcludeFromBackup;
copy.garbageCollectionInterval = self.garbageCollectionInterval;
copy.defaultExpirationPeriod = self.defaultExpirationPeriod;
@@ -146,6 +148,7 @@ - (NSString *)debugDescription
return SPTPersistentCacheObjectDescription(self,
self.cacheIdentifier, @"cache-identifier",
self.cachePath, @"cache-path",
+ self.shouldExcludeFromBackup, @"exclude-from-backup",
self.identifierForQueue, @"identifier-for-queue",
@(self.useDirectorySeparation), @"use-directory-separation",
@(self.garbageCollectionInterval), @"garbage-collection-interval",
diff --git a/Tests/Info.plist b/Tests/Info.plist
index 7659d3e..f6e7514 100644
--- a/Tests/Info.plist
+++ b/Tests/Info.plist
@@ -15,10 +15,10 @@
CFBundlePackageType
BNDL
CFBundleShortVersionString
- 1.1.1
+ 1.1.2
CFBundleSignature
????
CFBundleVersion
- 1.1.1
+ 1.1.2
diff --git a/include/SPTPersistentCache/SPTPersistentCacheOptions.h b/include/SPTPersistentCache/SPTPersistentCacheOptions.h
index 78efc42..ed54c89 100644
--- a/include/SPTPersistentCache/SPTPersistentCacheOptions.h
+++ b/include/SPTPersistentCache/SPTPersistentCacheOptions.h
@@ -114,6 +114,12 @@ FOUNDATION_EXPORT const NSUInteger SPTPersistentCacheMinimumExpirationLimit;
*/
@property (nonatomic, copy) NSString *cachePath;
+/**
+ Excludes the cache directory from backup.
+ @discussion Some users may wish to have the cache directory excluded from backup.
+ */
+@property (nonatomic, assign) BOOL shouldExcludeFromBackup;
+
/**
Whether directory separation of cache records should be used.
@discussion When enabled cached records are separate into direcectories based on the first two (2) characters in